chinwag-android/app/src/main/java/com/keylesspalace/tusky/CountUpDownLatch.java

26 lines
461 B
Java
Raw Normal View History

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();
}
}
}