302 |
|
public void testArrive2() { |
303 |
|
final Phaser phaser = new Phaser(); |
304 |
|
assertEquals(0, phaser.register()); |
305 |
< |
List<Thread> threads = new ArrayList<Thread>(); |
305 |
> |
List<Thread> threads = new ArrayList<>(); |
306 |
|
for (int i = 0; i < 10; i++) { |
307 |
|
assertEquals(0, phaser.register()); |
308 |
|
threads.add(newStartedThread(new CheckedRunnable() { |
620 |
|
public void testAwaitAdvance4() { |
621 |
|
final Phaser phaser = new Phaser(4); |
622 |
|
final AtomicInteger count = new AtomicInteger(0); |
623 |
< |
List<Thread> threads = new ArrayList<Thread>(); |
623 |
> |
List<Thread> threads = new ArrayList<>(); |
624 |
|
for (int i = 0; i < 4; i++) |
625 |
|
threads.add(newStartedThread(new CheckedRunnable() { |
626 |
|
public void realRun() { |
644 |
|
assertEquals(1, phaser.awaitAdvance(phaser.arrive())); |
645 |
|
assertEquals(1, phaser.getPhase()); |
646 |
|
assertEquals(1, phaser.register()); |
647 |
< |
List<Thread> threads = new ArrayList<Thread>(); |
647 |
> |
List<Thread> threads = new ArrayList<>(); |
648 |
|
for (int i = 0; i < 8; i++) { |
649 |
|
final CountDownLatch latch = new CountDownLatch(1); |
650 |
|
final boolean goesFirst = ((i & 1) == 0); |
672 |
|
*/ |
673 |
|
public void testAwaitAdvanceTieredPhaser() throws Exception { |
674 |
|
final Phaser parent = new Phaser(); |
675 |
< |
final List<Phaser> zeroPartyChildren = new ArrayList<Phaser>(3); |
676 |
< |
final List<Phaser> onePartyChildren = new ArrayList<Phaser>(3); |
675 |
> |
final List<Phaser> zeroPartyChildren = new ArrayList<>(3); |
676 |
> |
final List<Phaser> onePartyChildren = new ArrayList<>(3); |
677 |
|
for (int i = 0; i < 3; i++) { |
678 |
|
zeroPartyChildren.add(new Phaser(parent, 0)); |
679 |
|
onePartyChildren.add(new Phaser(parent, 1)); |
680 |
|
} |
681 |
< |
final List<Phaser> phasers = new ArrayList<Phaser>(); |
681 |
> |
final List<Phaser> phasers = new ArrayList<>(); |
682 |
|
phasers.addAll(zeroPartyChildren); |
683 |
|
phasers.addAll(onePartyChildren); |
684 |
|
phasers.add(parent); |
720 |
|
public void testAwaitAdvance6() { |
721 |
|
final Phaser phaser = new Phaser(3); |
722 |
|
final CountDownLatch pleaseForceTermination = new CountDownLatch(2); |
723 |
< |
final List<Thread> threads = new ArrayList<Thread>(); |
723 |
> |
final List<Thread> threads = new ArrayList<>(); |
724 |
|
for (int i = 0; i < 2; i++) { |
725 |
|
Runnable r = new CheckedRunnable() { |
726 |
|
public void realRun() { |
764 |
|
final Phaser phaser = new Phaser(1); |
765 |
|
final int THREADS = 3; |
766 |
|
final CountDownLatch pleaseArrive = new CountDownLatch(THREADS); |
767 |
< |
final List<Thread> threads = new ArrayList<Thread>(); |
767 |
> |
final List<Thread> threads = new ArrayList<>(); |
768 |
|
for (int i = 0; i < THREADS; i++) |
769 |
|
threads.add(newStartedThread(new CheckedRunnable() { |
770 |
|
public void realRun() { |