Changes
→Implementation
==Condition.java==
===Implementation===
Condition2 has a new state variable {{c|waitQueue}}, a ThreadQueue with transferPriority flag set to false.
* In the sleep() method, we disable interrupts, the current thread is added to the waitQueue of threads, the corresponding lock is released, and the current thread is put to sleep. When it wakes up, the thread attempts to reacquire the condition lock and interrupts are re-enabled.
* The wake() method disables interrupts and retrieves the next thread from the waitQueue. If the thread returned is not null, that thread calls ready(). Finally, wake() re-enables the interrupts.