1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
+ |
import java.util.*; |
8 |
|
import java.util.concurrent.*; |
8 |
– |
import java.util.concurrent.locks.*; |
9 |
|
import java.util.concurrent.atomic.*; |
10 |
< |
import java.util.*; |
10 |
> |
import java.util.concurrent.locks.*; |
11 |
|
|
12 |
|
public final class ContextSwitchTest { |
13 |
|
static final int iters = 1000000; |
37 |
|
} |
38 |
|
|
39 |
|
static final class MyThread extends Thread { |
40 |
+ |
|
41 |
+ |
static { |
42 |
+ |
// Reduce the risk of rare disastrous classloading in first call to |
43 |
+ |
// LockSupport.park: https://bugs.openjdk.java.net/browse/JDK-8074773 |
44 |
+ |
Class<?> ensureLoaded = LockSupport.class; |
45 |
+ |
} |
46 |
+ |
|
47 |
|
volatile Thread other; |
48 |
|
volatile int nparks; |
49 |
|
|
63 |
|
LockSupport.unpark(other); |
64 |
|
nparks = p; |
65 |
|
System.out.println("parks: " + p); |
59 |
– |
|
66 |
|
} |
67 |
|
} |
68 |
|
} |