32 * Expert Group and released to the public domain, as explained at
33 * http://creativecommons.org/publicdomain/zero/1.0/
34 */
35
36 package java.util.concurrent;
37
38 import java.security.AccessControlContext;
39 import java.security.AccessController;
40 import java.security.PrivilegedAction;
41 import java.security.ProtectionDomain;
42
43 /**
44 * A thread managed by a {@link ForkJoinPool}, which executes
45 * {@link ForkJoinTask}s.
46 * This class is subclassable solely for the sake of adding
47 * functionality -- there are no overridable methods dealing with
48 * scheduling or execution. However, you can override initialization
49 * and termination methods surrounding the main task processing loop.
50 * If you do create such a subclass, you will also need to supply a
51 * custom {@link ForkJoinPool.ForkJoinWorkerThreadFactory} to
52 * {@linkplain ForkJoinPool#ForkJoinPool use it} in a {@code ForkJoinPool}.
53 *
54 * @since 1.7
55 * @author Doug Lea
56 */
57 public class ForkJoinWorkerThread extends Thread {
58 /*
59 * ForkJoinWorkerThreads are managed by ForkJoinPools and perform
60 * ForkJoinTasks. For explanation, see the internal documentation
61 * of class ForkJoinPool.
62 *
63 * This class just maintains links to its pool and WorkQueue. The
64 * pool field is set immediately upon construction, but the
65 * workQueue field is not set until a call to registerWorker
66 * completes. This leads to a visibility race, that is tolerated
67 * by requiring that the workQueue field is only accessed by the
68 * owning thread.
69 *
70 * Support for (non-public) subclass InnocuousForkJoinWorkerThread
71 * requires that we break quite a lot of encapsulation (via helper
72 * methods in ThreadLocalRandom) both here and in the subclass to
|
32 * Expert Group and released to the public domain, as explained at
33 * http://creativecommons.org/publicdomain/zero/1.0/
34 */
35
36 package java.util.concurrent;
37
38 import java.security.AccessControlContext;
39 import java.security.AccessController;
40 import java.security.PrivilegedAction;
41 import java.security.ProtectionDomain;
42
43 /**
44 * A thread managed by a {@link ForkJoinPool}, which executes
45 * {@link ForkJoinTask}s.
46 * This class is subclassable solely for the sake of adding
47 * functionality -- there are no overridable methods dealing with
48 * scheduling or execution. However, you can override initialization
49 * and termination methods surrounding the main task processing loop.
50 * If you do create such a subclass, you will also need to supply a
51 * custom {@link ForkJoinPool.ForkJoinWorkerThreadFactory} to
52 * {@linkplain ForkJoinPool#ForkJoinPool(int, ForkJoinWorkerThreadFactory,
53 * UncaughtExceptionHandler, boolean, int, int, int, Predicate, long, TimeUnit)
54 * use it} in a {@code ForkJoinPool}.
55 *
56 * @since 1.7
57 * @author Doug Lea
58 */
59 public class ForkJoinWorkerThread extends Thread {
60 /*
61 * ForkJoinWorkerThreads are managed by ForkJoinPools and perform
62 * ForkJoinTasks. For explanation, see the internal documentation
63 * of class ForkJoinPool.
64 *
65 * This class just maintains links to its pool and WorkQueue. The
66 * pool field is set immediately upon construction, but the
67 * workQueue field is not set until a call to registerWorker
68 * completes. This leads to a visibility race, that is tolerated
69 * by requiring that the workQueue field is only accessed by the
70 * owning thread.
71 *
72 * Support for (non-public) subclass InnocuousForkJoinWorkerThread
73 * requires that we break quite a lot of encapsulation (via helper
74 * methods in ThreadLocalRandom) both here and in the subclass to
|