Package com.oorian
Class OorianWorkerThread
java.lang.Object
com.oorian.OorianWorkerThread
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 Summary
Modifier and TypeMethodDescriptionstatic OorianWorkerThreadCreates and queues a new worker thread with the specified task.static voidCreates and queues a new named worker thread.static voidcreate(ThreadGroup group, Runnable task) Creates and queues a new worker thread in the specified thread group.static voidcreate(ThreadGroup group, Runnable task, String name) Creates and queues a new named worker thread in the specified thread group.static voidcreate(ThreadGroup group, Runnable task, String name, long stackSize) Creates and queues a new worker thread with custom stack size.static voidcreate(ThreadGroup group, Runnable task, String name, long stackSize, boolean inheritThreadLocals) Creates and queues a new worker thread with full configuration options.booleanisAlive()Checks if the worker thread is currently running.final voidqueue()Queues this worker thread for execution after the current request completes.
-
Method Details
-
create
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
Creates and queues a new named worker thread.- Parameters:
task- the task to execute in the backgroundname- the thread name for debugging purposes
-
create
Creates and queues a new worker thread in the specified thread group.- Parameters:
group- the thread grouptask- the task to execute in the background
-
create
Creates and queues a new named worker thread in the specified thread group.- Parameters:
group- the thread grouptask- the task to execute in the backgroundname- the thread name
-
create
Creates and queues a new worker thread with custom stack size.- Parameters:
group- the thread grouptask- the task to execute in the backgroundname- the thread namestackSize- 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 grouptask- the task to execute in the backgroundname- the thread namestackSize- the desired stack size in bytesinheritThreadLocals- 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
OorianSessionand 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
-