Package com.oorian

Class OorianWorkerThread

java.lang.Object
com.oorian.OorianWorkerThread

public class OorianWorkerThread extends Object
Factory and wrapper for background worker threads within an Oorian session.

OorianWorkerThread provides a mechanism for creating background threads that are associated with the current user session. Worker threads are queued and started after the main request processing completes, preventing issues with concurrent access to session resources.

Key Features:

  • Session-aware thread creation
  • Automatic queuing to prevent race conditions
  • Multiple factory methods for different Thread configurations
  • Integration with OorianSession for lifecycle management

Usage:


 // Create and queue a simple worker thread
 OorianWorkerThread.create(() -> {
     // Background processing
     sendEmailNotification(user);
 });

 // Create with a name for debugging
 OorianWorkerThread.create(() -> {
     processLargeDataSet(data);
 }, "DataProcessor");
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Method Details

    • create

      public static OorianWorkerThread create(Runnable task)
      Creates and queues a new worker thread with the specified task.
      Parameters:
      task - the task to execute in the background
      Returns:
      the created worker thread
    • create

      public static void create(Runnable task, String name)
      Creates and queues a new named worker thread.
      Parameters:
      task - the task to execute in the background
      name - the thread name for debugging purposes
    • create

      public static void create(ThreadGroup group, Runnable task)
      Creates and queues a new worker thread in the specified thread group.
      Parameters:
      group - the thread group
      task - the task to execute in the background
    • create

      public static void create(ThreadGroup group, Runnable task, String name)
      Creates and queues a new named worker thread in the specified thread group.
      Parameters:
      group - the thread group
      task - the task to execute in the background
      name - the thread name
    • create

      public static void create(ThreadGroup group, Runnable task, String name, long stackSize)
      Creates and queues a new worker thread with custom stack size.
      Parameters:
      group - the thread group
      task - the task to execute in the background
      name - the thread name
      stackSize - the desired stack size in bytes
    • create

      public static void create(ThreadGroup group, Runnable task, String name, long stackSize, boolean inheritThreadLocals)
      Creates and queues a new worker thread with full configuration options.
      Parameters:
      group - the thread group
      task - the task to execute in the background
      name - the thread name
      stackSize - the desired stack size in bytes
      inheritThreadLocals - whether to inherit inheritable thread-locals
    • queue

      public final void queue()
      Queues this worker thread for execution after the current request completes.

      The thread is registered with the current OorianSession and will be started automatically when the session is ready to process background work.

    • isAlive

      public boolean isAlive()
      Checks if the worker thread is currently running.
      Returns:
      true if the thread is alive