24 |
|
import java.util.concurrent.RecursiveTask; |
25 |
|
import java.util.concurrent.RejectedExecutionException; |
26 |
|
import java.util.concurrent.atomic.AtomicBoolean; |
27 |
+ |
import java.util.concurrent.atomic.AtomicInteger; |
28 |
|
import java.util.concurrent.locks.ReentrantLock; |
29 |
|
|
30 |
|
import junit.framework.AssertionFailedError; |
58 |
|
|
59 |
|
// Some classes to test extension and factory methods |
60 |
|
|
60 |
– |
static class MyHandler implements Thread.UncaughtExceptionHandler { |
61 |
– |
volatile int catches = 0; |
62 |
– |
public void uncaughtException(Thread t, Throwable e) { |
63 |
– |
++catches; |
64 |
– |
} |
65 |
– |
} |
66 |
– |
|
61 |
|
static class MyError extends Error {} |
62 |
|
|
63 |
|
// to test handlers |
68 |
|
|
69 |
|
static class FailingThreadFactory |
70 |
|
implements ForkJoinPool.ForkJoinWorkerThreadFactory { |
71 |
< |
volatile int calls = 0; |
71 |
> |
final AtomicInteger calls = new AtomicInteger(0); |
72 |
|
public ForkJoinWorkerThread newThread(ForkJoinPool p) { |
73 |
< |
if (++calls > 1) return null; |
73 |
> |
if (calls.incrementAndGet() > 1) return null; |
74 |
|
return new FailingFJWSubclass(p); |
75 |
|
} |
76 |
|
} |