Waiting on a condition in a reentrant lock

前端 未结 3 861
無奈伤痛
無奈伤痛 2021-02-01 16:02

The following code is taken from the JavaDoc of Condition:

class BoundedBuffer {
  final Lock lock = new ReentrantLock();
  final Condition notFull  = lock.newCo         


        
3条回答
  •  梦如初夏
    2021-02-01 16:37

    As far as re-entrancy, this means that a thread that holds a certain lock can re-acquire the same lock again. If this wasn't so, a synchronized method would not be able to call another synchronized method of the same object.

    Re-entrancy is not involved in the understanding of your problem.

提交回复
热议问题