public static class SessionFactory.SessionCloseThread
extends java.lang.Thread
| Modifier and Type | Field and Description |
|---|---|
private static java.util.Queue<SessionFactory> |
factories
A thread-safe queue that stores all SessionFactory instances created.
|
private static boolean |
initialized
Value used to check if the thread is initialized.
|
private static int |
lifespan
Lifespan of a thread (ms).
|
| Modifier | Constructor and Description |
|---|---|
private |
SessionCloseThread()
Constructor that initializes the Queue and initializes
the current thread as a Daemon thread.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
deregister(SessionFactory factory)
Removes a SessionFactory instance from the queue.
|
static void |
initialize()
Creates an instance of the Thread and starts it.
|
private static void |
register(SessionFactory factory)
Add a SessionFactory instance to the queue managed
by the thread.
|
private void |
removeIdleSessions()
Removes any sessions that have exceeded their lifespan from
all existent factories.
|
void |
run()
The thread sleeps for the duration of a lifespan,
then it calls the method for removing expired sessions.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprivate static int lifespan
private static java.util.Queue<SessionFactory> factories
private static boolean initialized
private SessionCloseThread()
public static void initialize()
private static void register(SessionFactory factory)
factory - A SessionFactory instance.public static void deregister(SessionFactory factory)
factory - A SessionFactory instance.public void run()
run in interface java.lang.Runnablerun in class java.lang.Threadprivate void removeIdleSessions()