Java Concurrency in Practice - Sample 14.12

后端 未结 3 1577
夕颜
夕颜 2020-12-05 10:56
// Not really how java.util.concurrent.Semaphore is implemented
@ThreadSafe
public class SemaphoreOnLock {
    private final Lock lock = new ReentrantLock();
    //          


        
3条回答
  •  长情又很酷
    2020-12-05 11:20

    I honestly don't see any valid use for the lock here, other than the fact that it introduces a memory fence. int assignments are atomic on 32/64 bit anyway.

提交回复
热议问题