Difference in internal storing between 'fair' and 'unfair' lock
问题 The way Lock interface with class Reentrant(true) lock works is that it uses BlockingQueue to store Threads that want to acquire the lock . In that way thread that 'came first, go out first'-FIFO. All clear about that. But where do 'unfair locks' go, or ReentrantLock(false). What is their internal implementation? How does OS decide which thread now to pick? And most importantly are now these threads also stored in a queue or where? (they must be somewhere) 回答1: The class ReentrantLock does