Class ThreadHelper

java.lang.Object
com.github.eventmanager.internal.ThreadHelper

public class ThreadHelper extends Object
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 Details

    • ThreadHelper

      public ThreadHelper()
  • Method Details

    • startEventThread

      public void startEventThread(Runnable runnable)
      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

      public void startProcessingThread(Runnable runnable)
      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 provided Consumer.
      Parameters:
      thread - the Thread instance to stop.
      queue - the BlockingQueue holding the remaining events to be processed.
      remainingItemProcessor - a Consumer to process remaining events from the queue after interruption.