1 package com.freemindcafe.concurrency.sample6;
3 import java.util.concurrent.CyclicBarrier;
8 public void test_using_custom_barrier()
throws Exception{
13 System.out.println(
"before in r1");
15 System.out.println(
"after in r1");
24 System.out.println(
"before in r2");
26 System.out.println(
"after in r2");
33 Thread t1 =
new Thread(r1);
34 Thread t2 =
new Thread(r2);
45 public void test_using_jdk_barrier()
throws Exception{
46 CyclicBarrier barrier =
new CyclicBarrier(2);
50 System.out.println(
"before in r1");
52 System.out.println(
"after in r1");
61 System.out.println(
"before in r2");
63 System.out.println(
"after in r2");
70 Thread t1 =
new Thread(r1);
71 Thread t2 =
new Thread(r2);