Skip to content

Commit f9372d7

Browse files
committed
Simple example wishing what needs to happen
0 parents  commit f9372d7

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.class

BarrierExample.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class BarrierExample {
2+
3+
public static void main(String args[]){
4+
for(int i=0; i<50; i++) {
5+
new Thread(new Worker()).start();
6+
}
7+
}
8+
9+
}

Worker.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
public class Worker implements Runnable {
2+
3+
public void log(String message) {
4+
System.out.println(Thread.currentThread().getName() + ": " + message);
5+
}
6+
7+
public void run(){
8+
log("running");
9+
log("this should happen before reaching the barrier");
10+
11+
// TODO: insert barrier here
12+
log("this should happen after the barrier");
13+
}
14+
15+
}

0 commit comments

Comments
 (0)