Code example for CyclicBarrier

0
public class SynchronizedTSample { 
	public static void main(String[] args) {
		final ExecutorService es = Executors.newFixedThreadPool(3);
		final CountDownLatch cdl = new CountDownLatch(1);
		final CyclicBarrier barrier1 = new CyclicBarrier(3);
		final CyclicBarrier barrier2 = new CyclicBarrier(3);
		es.execute(new Runnable() {
			@Override 
			public void run() { 
				await(cdl);
				for (int i = 0; i < 3; i++) {
					System.out.println("1");
					System.out.println("2");
					try { 
						barrier1.await();
						System.out.println("あ");
						barrier2.await();
					} catch (InterruptedException | BrokenBarrierException e) {}
				} 
			} 
		});