Package com.example.server.handler
Class SimpleHandleThread<T>
java.lang.Object
java.lang.Thread
com.example.server.handler.SimpleHandleThread<T>
- All Implemented Interfaces:
HandleThread
,Runnable
Class - implementation of message processing as a usual Thread.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleHandleThread
(MessageQueue<T> messageQueue, MessageHandler<T> messageHandler) Constructor for SimpleHandleThread. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if the thread is currently processing messages.void
Stop the execution of the current thread.void
run()
Main processing loop of the 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
Methods inherited from interface com.example.server.handler.HandleThread
start
-
Constructor Details
-
SimpleHandleThread
Constructor for SimpleHandleThread.- Parameters:
messageQueue
- The message queue for storing incoming messages.messageHandler
- The message handler to process the messages.
-
-
Method Details
-
isProcessing
public boolean isProcessing()Check if the thread is currently processing messages.- Specified by:
isProcessing
in interfaceHandleThread
- Returns:
- true if the thread is actively processing messages.
-
killThread
public void killThread()Stop the execution of the current thread.- Specified by:
killThread
in interfaceHandleThread
-
run
public void run()Main processing loop of the thread. It continuously retrieves and processes messages from the message queue until interrupted.
-