Item 84. Thread Scheduler
1. μ€ν κ°λ₯ν μ€λ λμ μλ₯Ό μ κ² μ μ§
2. λ°μ λκΈ° μν ννΌ
public class SlowCountDownLatch {
private int count;
public SlowCountDownLatch(int count) {
if (count < 0) {
throw new IllegalArgumentException(count + " < 0");
}
this.count = count;
}
public void await() {
// μνλ₯Ό κ³μ κ²μ¬νλ©΄μ λ°μ λκΈ° μνμ λΉ μ§
while (true) {
synchronized (this) {
if (count == 0) {
return;
}
}
}
}
public synchronized void countDown() {
if (count != 0) {
count--;
}
}
}3. μ€λ λ μ°μ μμλ₯Ό μ‘°μ νμ§ μκΈ°
Last updated