Does making a Reentrant Lock static and make it a mutex?

后端 未结 2 1105
暗喜
暗喜 2021-02-08 04:46

In Brian Goetz\'s book, Java Concurrency in Practice, his example of a Reentrant lock is programmed like this:

Lock lock = new ReentrantLock();

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-08 05:21

    Creating a static Lock is equivallent to

    synchronized(MyClass.class){
    
    }
    

    Its in essence a class level lock

提交回复
热议问题