java.util.concurrent.locks.Condition.await()가 루프 내부에서 호출되지 않는 경우를 보고합니다.
await() 및 관련 메서드는 보통 어떤 조건이 true가 될 때까지 스레드를 중지하기 위해 사용됩니다.
스레드가 다른 이유로 시작되었을 수 있으므로 await() 호출이 반환된 후 조건을 검사해야 합니다.
루프는 이를 수행하기 위한 간단한 방법입니다.
예:
void acquire(Condition released) throws InterruptedException {
released.await();
}
좋은 코드는 다음과 같습니다.
void acquire(Condition released) throws InterruptedException {
while (acquired) {
released.await();
}
}