Class WorkerThread

  • All Implemented Interfaces:
    java.lang.Runnable

    final class WorkerThread
    extends java.lang.Thread
    This is a worker thread. This is given commands to execute by the WorkerPool.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Runnable command
      The Runnable command we are currently processing.
      private static boolean DISPLAY_COMMAND_TIME
      If this is set to true, the server displays the time each executed command took.
      private boolean shutdown
      Set to true to turn off this worker thread.
      private long start_time
      The time the command was started.
      private WorkerPool worker_pool
      The WorkerPool object that this worker thread is for.
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • 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
      DebugLogger Debug()
      Returns a DebugLogger object we can use to log debug messages.
      (package private) void execute​(User user, DatabaseConnection database_connection, java.lang.Runnable runner)
      Tells the worker thread that the user is executing the given command.
      void run()
      Starts executing this worker thread.
      (package private) void shutdown()
      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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread