Skip to content

Commit e3543ea

Browse files
1.并发包学习
1 parent 9b42740 commit e3543ea

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.concurrent.cyclicBarrierLearn;
2+
3+
import java.util.concurrent.CyclicBarrier;
4+
5+
/**
6+
* @ClassName CyclicBarrierLearnOne
7+
* @Despacito TODO
8+
* @Author chenzhuo
9+
* @Version 1.0
10+
**/
11+
public class CyclicBarrierLearnOne {
12+
13+
private static CyclicBarrier barrier;
14+
15+
public static void main(String[] args) {
16+
barrier = new CyclicBarrier(3, () -> System.out.println("开始~~~"));
17+
for(int i =0;i<3;i++){
18+
new CyRun().start();
19+
}
20+
}
21+
22+
public static class CyRun extends Thread{
23+
24+
@Override
25+
public void run() {
26+
System.out.println(Thread.currentThread().getName() + "到了");
27+
try {
28+
barrier.await();
29+
} catch (Exception e) {
30+
e.printStackTrace();
31+
}
32+
}
33+
}
34+
35+
}

0 commit comments

Comments
 (0)