Package org.sonews.daemon
Class DaemonThread
java.lang.Object
java.lang.Thread
org.sonews.daemon.DaemonThread
- All Implemented Interfaces:
Runnable
Base class of all sonews threads. Instances of this class will be
automatically registered at the ShutdownHook to be cleanly exited when the
server is forced to exit.
- Since:
- sonews/0.5.0
- Author:
- Christian Lins
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionDaemonThread
(Runnable run) Constructs a new DaemonThread with the given Runnable. -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
Marks this thread to exit soon.protected void
setRunning
(boolean running) Set the running state of this daemon.void
start()
Starts this daemon.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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
DaemonThread
Constructs a new DaemonThread with the given Runnable.- Parameters:
run
-
-
-
Method Details
-
isRunning
public boolean isRunning()- Returns:
- true if shutdown() was not yet called.
-
setRunning
protected void setRunning(boolean running) Set the running state of this daemon.- Parameters:
running
-
-
requestShutdown
public void requestShutdown()Marks this thread to exit soon. Closes the associated JDBCDatabase connection if available. -
start
public void start()Starts this daemon.
-