java.lang.Object
com.github.eventmanager.internal.ThreadHelper
Helper class responsible for managing event-related threads within the EventManager library.
Provides functionality for:
- Starting and managing threads specifically for event processing and logging.
- Gracefully stopping threads, ensuring queued events are fully processed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
startEventThread
(Runnable runnable) Starts and manages the event logging thread, executing the provided runnable task.void
startProcessingThread
(Runnable runnable) Starts and manages the event processing thread, executing the provided runnable task.void
stopThread
(Thread thread, BlockingQueue<String> queue, Consumer<String> remainingItemProcessor) Gracefully interrupts and stops the specified thread, ensuring all remaining queued events are processed using the providedConsumer
.
-
Constructor Details
-
ThreadHelper
public ThreadHelper()
-
-
Method Details
-
startEventThread
Starts and manages the event logging thread, executing the provided runnable task.- Parameters:
runnable
- the task to run in the event thread, typically involving log-writing operations.
-
startProcessingThread
Starts and manages the event processing thread, executing the provided runnable task.- Parameters:
runnable
- the task to run in the processing thread, typically involving pre-processing or modifying event data.
-
stopThread
public void stopThread(Thread thread, BlockingQueue<String> queue, Consumer<String> remainingItemProcessor) Gracefully interrupts and stops the specified thread, ensuring all remaining queued events are processed using the providedConsumer
.- Parameters:
thread
- theThread
instance to stop.queue
- theBlockingQueue
holding the remaining events to be processed.remainingItemProcessor
- aConsumer
to process remaining events from the queue after interruption.
-