前言
ReentrantLock是非常常用的鎖,在前面【從入門到放棄-Java】併發編程-JUC-LinkedBlockingQueue在我們瞭解到,LinkedBlockingQueue入隊、出隊都是依賴ReentrantLock進行鎖同步和線程喚醒、等待的。
本文來學習下ReentrantLock。
ReentrantLock
/**
* Creates an instance of {@code ReentrantLock}.
* This is equivalent to using {@code ReentrantLock(false)}.
*/
public ReentrantLock() {
sync = new NonfairSync();
}
/**
* Creates an instance of {