You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

25 lines
461 B

package com.keylesspalace.tusky;
public class CountUpDownLatch {
private int count;
public CountUpDownLatch() {
this.count = 0;
}
public synchronized void countDown() {
count--;
notifyAll();
}
public synchronized void countUp() {
count++;
notifyAll();
}
public synchronized void await() throws InterruptedException {
while (count != 0) {
wait();
}
}
}