4 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
< |
import java.util.*; |
8 |
< |
import java.util.concurrent.*; |
9 |
< |
import java.util.concurrent.locks.*; |
10 |
< |
import java.util.concurrent.atomic.*; |
7 |
> |
import java.util.Random; |
8 |
> |
import java.util.Queue; |
9 |
|
|
10 |
|
public class UnboundedQueueFillEmptyLoops { |
11 |
|
static int maxSize = 10000; |
43 |
|
} |
44 |
|
|
45 |
|
static void oneRun(Class<?> klass, int n) throws Exception { |
46 |
< |
Queue<Integer> q = (Queue<Integer>) klass.newInstance(); |
46 |
> |
Queue<Integer> q = |
47 |
> |
(Queue<Integer>) klass.getConstructor().newInstance(); |
48 |
|
int sum = total; |
49 |
|
int m = rng.nextInt(numbers.length); |
50 |
|
long startTime = System.nanoTime(); |
54 |
|
m = 0; |
55 |
|
q.offer(numbers[m++]); |
56 |
|
} |
57 |
< |
Integer p; |
59 |
< |
while ((p = q.poll()) != null) |
57 |
> |
for (Integer p; (p = q.poll()) != null; ) |
58 |
|
sum += p.intValue(); |
59 |
|
} |
60 |
|
total += sum; |