1 |
|
/* |
2 |
< |
* @test %I% %E% |
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/publicdomain/zero/1.0/ |
5 |
> |
*/ |
6 |
> |
/* |
7 |
> |
* @test |
8 |
|
* @bug 4486658 |
9 |
|
* @compile -source 1.5 TimeoutLockLoops.java |
10 |
|
* @run main TimeoutLockLoops |
23 |
|
static final LoopHelpers.SimpleRandom rng = new LoopHelpers.SimpleRandom(); |
24 |
|
static boolean print = false; |
25 |
|
static final int ITERS = Integer.MAX_VALUE; |
26 |
< |
static final long TIMEOUT = 100; |
26 |
> |
static final long TIMEOUT = 100; |
27 |
|
|
28 |
|
public static void main(String[] args) throws Exception { |
29 |
|
int maxThreads = 100; |
30 |
< |
if (args.length > 0) |
30 |
> |
if (args.length > 0) |
31 |
|
maxThreads = Integer.parseInt(args[0]); |
32 |
|
|
33 |
|
print = true; |
66 |
|
barrier.await(); |
67 |
|
if (print) { |
68 |
|
long time = timer.getTime(); |
69 |
< |
double secs = (double)(time) / 1000000000.0; |
69 |
> |
double secs = (double) time / 1000000000.0; |
70 |
|
System.out.println("\t " + secs + "s run time"); |
71 |
|
} |
72 |
|
|
79 |
|
|
80 |
|
public final void run() { |
81 |
|
try { |
82 |
< |
barrier.await(); |
82 |
> |
barrier.await(); |
83 |
|
int sum = v; |
84 |
|
int x = 17; |
85 |
|
int n = ITERS; |
104 |
|
barrier.await(); |
105 |
|
result += sum; |
106 |
|
} |
107 |
< |
catch (Exception ex) { |
107 |
> |
catch (Exception ex) { |
108 |
|
ex.printStackTrace(); |
109 |
< |
return; |
109 |
> |
return; |
110 |
|
} |
111 |
|
} |
112 |
|
} |