平静

遵循美德行事,纵使没有增加快乐,也可减轻焦虑。

导航

匿名类

Posted on 2016-10-27 14:15  mdong  阅读(96)  评论(0编辑  收藏  举报

  

public class CyclicBarrierTest2 {

	static CyclicBarrier c = new CyclicBarrier(2, new A());

	public static void main(String[] args) {
		new Thread(new Runnable() {

			@Override
			public void run() {
				try {
					c.await();
				} catch (Exception e) {

				}
				System.out.println(1);
			}
		}).start();

		try {
			c.await();
		} catch (Exception e) {

		}
		System.out.println(2);
	}

	static class A implements Runnable {

		@Override
		public void run() {
			System.out.println(3);
		}

	}

}