-
requirement
-
functionality
- acquire
- release
- nonblocking synchronization attempts(tryLock)
- timeout
- cancel
- exclusive state
- shared state
-
performance
-
scalability
- 不管多少线程,当通过同一个同步点时,开销应当是常量
-
design
- atomically managing synchronization state
- blocking and unblocking threads
- maintaining queues
-
implement
-
synchronization state
- 32bit int
- compareAndSetState
-
blocking
- LockSupport.park
- LockSupport.unpark
-
queues
-
lock queue
-
CLH variant
- head
- predecessor
- sucessor
- tail
- node status
- condition queue
-
fairness
- barging thread
- head node thread
-
usage
- 作为内部类
-
performance
- overhead
- throughput