Package net.bjmsw.hda.vs.helper
Class GarbageCollector
java.lang.Object
java.lang.Thread
net.bjmsw.hda.vs.helper.GarbageCollector
- All Implemented Interfaces:
Runnable
The GarbageCollector class provides a garbage collection mechanism for the server.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intThe TICK_RATE variable represents the rate at which the garbage collector runs.private static final intThe USER_TIMEOUT variable represents the amount of time, in seconds, after which a user session will be considered inactive and removed.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidThe checkUserTimeout method checks for inactive user sessions and removes them from the system.voidrun()Runs the garbage collector thread.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Field Details
-
TICK_RATE
private static final int TICK_RATEThe TICK_RATE variable represents the rate at which the garbage collector runs. It is set to 5000 milliseconds, which is equivalent to 5 seconds.This variable is used in the GarbageCollector class to control the frequency of garbage collection ticks.
- See Also:
-
USER_TIMEOUT
private static final int USER_TIMEOUTThe USER_TIMEOUT variable represents the amount of time, in seconds, after which a user session will be considered inactive and removed. By default, it is set to 120 seconds, which is equivalent to 2 minutes.This variable is used in the GarbageCollector class to determine if a user has exceeded the allowed timeout period and needs to be removed from the system.
- See Also:
-
-
Constructor Details
-
GarbageCollector
public GarbageCollector()
-
-
Method Details
-
checkUserTimeout
private void checkUserTimeout()The checkUserTimeout method checks for inactive user sessions and removes them from the system. -
run
public void run()Runs the garbage collector thread. This method runs in an infinite loop and performs garbage collection ticks at a regular rate. It checks for inactive user sessions and removes them from the system.
-