Package com.mckoi.database
Class WorkerThread
- java.lang.Object
-
- java.lang.Thread
-
- com.mckoi.database.WorkerThread
-
- All Implemented Interfaces:
java.lang.Runnable
final class WorkerThread extends java.lang.ThreadThis is a worker thread. This is given commands to execute by the WorkerPool.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.RunnablecommandThe Runnable command we are currently processing.private static booleanDISPLAY_COMMAND_TIMEIf this is set to true, the server displays the time each executed command took.private booleanshutdownSet to true to turn off this worker thread.private longstart_timeThe time the command was started.private WorkerPoolworker_poolThe WorkerPool object that this worker thread is for.
-
Constructor Summary
Constructors Constructor Description WorkerThread(WorkerPool worker_pool)Constructs the thread.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DebugLoggerDebug()Returns a DebugLogger object we can use to log debug messages.(package private) voidexecute(User user, DatabaseConnection database_connection, java.lang.Runnable runner)Tells the worker thread that the user is executing the given command.voidrun()Starts executing this worker thread.(package private) voidshutdown()Shuts down this worker 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 Detail
-
DISPLAY_COMMAND_TIME
private static final boolean DISPLAY_COMMAND_TIME
If this is set to true, the server displays the time each executed command took.- See Also:
- Constant Field Values
-
shutdown
private boolean shutdown
Set to true to turn off this worker thread.
-
command
private java.lang.Runnable command
The Runnable command we are currently processing.
-
start_time
private long start_time
The time the command was started.
-
worker_pool
private WorkerPool worker_pool
The WorkerPool object that this worker thread is for.
-
-
Constructor Detail
-
WorkerThread
public WorkerThread(WorkerPool worker_pool)
Constructs the thread.
-
-
Method Detail
-
Debug
public final DebugLogger Debug()
Returns a DebugLogger object we can use to log debug messages.
-
shutdown
void shutdown()
Shuts down this worker thread.
-
execute
void execute(User user, DatabaseConnection database_connection, java.lang.Runnable runner)
Tells the worker thread that the user is executing the given command.
-
run
public void run()
Starts executing this worker thread.- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
-