ForkJoinPool, which executes
ForkJoinTasks.
This class is subclassable solely for the sake of adding
functionality -- there are no overridable methods dealing with
scheduling or execution. However, you can override initialization
and termination methods surrounding the main task processing loop.
If you do create such a subclass, you will also need to supply a
custom ForkJoinPool.ForkJoinWorkerThreadFactory to
use it in a ForkJoinPool.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | ForkJoinWorkerThread.
A worker thread that is not a member of any user-defined ThreadGroup, uses the system class loader as thread context class loader, and clears all ThreadLocals after running each top-level task. |
| Modifier and Type | Field and Description |
|---|---|
| private static final long | |
| private static final JavaLangAccess | |
| pack-priv final ForkJoinPool | |
| private static final long | |
| private static final Unsafe | |
| pack-priv final ForkJoinPool. |
| Access | Constructor and Description |
|---|---|
| pack-priv | ForkJoinWorkerThread(ThreadGroup group, ForkJoinPool pool, boolean useSystemClassLoader, boolean clearThreadLocals)
Full nonpublic constructor. |
| protected | ForkJoinWorkerThread(ThreadGroup
if non-null, the thread group for this
thread. Otherwise, the thread group is set to the current thread's
thread group. group, ForkJoinPool the pool this thread works in pool, boolean if true, always preserve the values of
ThreadLocal variables across tasks; otherwise they may be cleared. preserveThreadLocals)Creates a ForkJoinWorkerThread operating in the given thread group and pool, and with the given policy for preserving ThreadLocals. |
| protected | ForkJoinWorkerThread(ForkJoinPool
the pool this thread works in pool)Creates a ForkJoinWorkerThread operating in the given pool. |
| Modifier and Type | Method and Description |
|---|---|
| public ForkJoinPool | |
| public int | |
| public int | Returns: a (non-negative) estimate of the number of tasks in the thread's queueReturns a (non-negative) estimate of the number of tasks in the thread's queue. |
| pack-priv static boolean | Returns: true if the current task is being executed by a worker that has queued workReturns true if the current task is being executed by a ForkJoinWorkerThread that is momentarily known to have one or more queued tasks that it could execute immediately. |
| protected void | |
| protected void | onTermination(Throwable
the exception causing this thread to abort due
to an unrecoverable error, or exception)null if completed normallyPerforms cleanup associated with termination of this worker thread. |
| pack-priv void | onThreadLocalReset()
Performs any further cleanup after ThreadLocals are cleared in method resetThreadLocals |
| pack-priv final void | |
| public void | run()
Overrides java. Implements java. This method is required to be public, but should never be called explicitly. |
| INHERITABLETHREADLOCALS | back to summary |
|---|---|
| private static final long INHERITABLETHREADLOCALS | |
| JLA | back to summary |
|---|---|
| private static final JavaLangAccess JLA | |
| pool | back to summary |
|---|---|
| pack-priv final ForkJoinPool pool | |
| THREADLOCALS | back to summary |
|---|---|
| private static final long THREADLOCALS | |
| U | back to summary |
|---|---|
| private static final Unsafe U | |
| workQueue | back to summary |
|---|---|
| pack-priv final ForkJoinPool. | |
| ForkJoinWorkerThread | back to summary |
|---|---|
| pack-priv ForkJoinWorkerThread(ThreadGroup group, ForkJoinPool pool, boolean useSystemClassLoader, boolean clearThreadLocals) Full nonpublic constructor. | |
| ForkJoinWorkerThread | back to summary |
|---|---|
| protected ForkJoinWorkerThread(ThreadGroup group, ForkJoinPool pool, boolean preserveThreadLocals) Creates a ForkJoinWorkerThread operating in the given thread group and pool, and with the given policy for preserving ThreadLocals.
| |
| ForkJoinWorkerThread | back to summary |
|---|---|
| protected ForkJoinWorkerThread(ForkJoinPool pool) Creates a ForkJoinWorkerThread operating in the given pool.
| |
| getPool | back to summary |
|---|---|
| public ForkJoinPool getPool() Returns the pool hosting this thread.
| |
| getPoolIndex | back to summary |
|---|---|
| public int getPoolIndex() Returns the unique index number of this thread in its pool. The returned value ranges from zero to the maximum number of threads (minus one) that may exist in the pool, and does not change during the lifetime of the thread. This method may be useful for applications that track status or collect results per-worker-thread rather than per-task.
| |
| getQueuedTaskCount | back to summary |
|---|---|
| public int getQueuedTaskCount() Returns a (non-negative) estimate of the number of tasks in the thread's queue.
| |
| hasKnownQueuedWork | back to summary |
|---|---|
| pack-priv static boolean hasKnownQueuedWork() Returns true if the current task is being executed by a ForkJoinWorkerThread that is momentarily known to have one or more queued tasks that it could execute immediately. This method is approximate and useful only as a heuristic indicator within a running task.
| |
| onStart | back to summary |
|---|---|
| protected void onStart() Initializes internal state after construction but before
processing any tasks. If you override this method, you must
invoke | |
| onTermination | back to summary |
|---|---|
| protected void onTermination(Throwable exception) Performs cleanup associated with termination of this worker
thread. If you override this method, you must invoke
| |
| onThreadLocalReset | back to summary |
|---|---|
| pack-priv void onThreadLocalReset() Performs any further cleanup after ThreadLocals are cleared in method resetThreadLocals | |
| resetThreadLocals | back to summary |
|---|---|
| pack-priv final void resetThreadLocals() Clears ThreadLocals | |
| run | back to summary |
|---|---|
| public void run() Overrides java. Implements java. This method is required to be public, but should never be
called explicitly. It performs the main run loop to execute
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final ThreadGroup | innocuousThreadGroup
The ThreadGroup for all InnocuousForkJoinWorkerThreads |
| private boolean |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static ThreadGroup | |
| pack-priv final void | onThreadLocalReset()
Overrides java. Performs any further cleanup after ThreadLocals are cleared in method resetThreadLocals |
| public void | setContextClassLoader(ClassLoader cl)
Overrides java. Sets the context |
| public void | setUncaughtExceptionHandler(Thread.
Overrides java. Set the handler invoked when this thread abruptly terminates due to an uncaught exception. |
| innocuousThreadGroup | back to summary |
|---|---|
| private static final ThreadGroup innocuousThreadGroup The ThreadGroup for all InnocuousForkJoinWorkerThreads | |
| resetCCL | back to summary |
|---|---|
| private boolean resetCCL | |
| InnocuousForkJoinWorkerThread | back to summary |
|---|---|
| pack-priv InnocuousForkJoinWorkerThread(ForkJoinPool pool) | |
| createGroup | back to summary |
|---|---|
| pack-priv static ThreadGroup createGroup() | |
| onThreadLocalReset | back to summary |
|---|---|
| pack-priv final void onThreadLocalReset() Overrides java. Doc from java. Performs any further cleanup after ThreadLocals are cleared in method resetThreadLocals
| |
| setContextClassLoader | back to summary |
|---|---|
| public void setContextClassLoader(ClassLoader cl) Overrides java. Doc from java. Sets the context The context
| |
| setUncaughtExceptionHandler | back to summary |
|---|---|
| public void setUncaughtExceptionHandler(Thread. Overrides java. Doc from java. Set the handler invoked when this thread abruptly terminates due to an uncaught exception. A thread can take full control of how it responds to uncaught
exceptions by having its uncaught exception handler explicitly set.
If no such handler is set then the thread's
| |