class Barrier{
private int releaseNum;
private int count;
Barrier(int num){
releaseNum = num;
count = 0;
}
public synchronized void check(){
count++;
if(count < releaseNum){
try { wait();}
catch(InterruptedException e){}
}
else{
count = 0;
notifyAll();
} } }
Previous slide | Next slide | Back to first slide | View graphic version |