Home >Java >javaTutorial >What is the status of java thread execution?
1. If the queue is full, the new thread performing the put operation will be added to the notFull condition queue to wait.
2. The queue is not full. When a thread performs the operation of removing queue elements, the removal is successful and the put thread is awakened.
Example
public E take() throws InterruptedException { final ReentrantLock lock = this.lock; lock.lockInterruptibly(); try { // 队列长度为0 while (count == 0) // 阻塞 notEmpty.await(); // 如果队列有元素执行删除操作 return dequeue(); } finally { lock.unlock(); } } /** Condition for waiting takes */ private final Condition notEmpty;
The above is the detailed content of What is the status of java thread execution?. For more information, please follow other related articles on the PHP Chinese website!