26 lines
461 B
Java
26 lines
461 B
Java
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|