only plain text
only plain text
only plain text
only plain text
only plain text
only plain text
only plain text
1 import java.util.concurrent.*; 2 import java.util.stream.*; 3 public class test{ 4 public static void await(CyclicBarrier cb) { 5 try { 6 cb.await(); 7 } catch (InterruptedException | BrokenBarrierException e) { 8 // 9 } 10 } 11 public static void main(String...args) { 12 final CyclicBarrier cb = new CyclicBarrier(3, ()-> System.out.println("Pass!")); 13 ExecutorService service = Executors.newScheduledThreadPool(3); 14 IntStream.iterate(1, i->1) 15 .limit(7) 16 .forEach(i->service.submit( 17 ()->await(cb))); 18 service.shutdown(); 19 } 20 }
only plain text
only plain text
only plain text
only plain text
only plain text
only plain text
only plain text
only plain text
only plain textonly plain text
only plain text
only plain text
only plain text
only plain text
only plain text