Thread Safety with Phaser, StampedLock and VarHandle
summary
Live demos compare wait/notify, ReentrantLock+Condition, CountDownLatch, volatile spin and Phaser (arriveAndAwaitAdvance) for synchronized starts and show phaser wins (single-digit microsecond max spread, total ~8Mns across runs), volatile spin is second best, wait/notify and countdown perform worse. StampedLock optimistic reads give ~30x improvement over naive locking for a position update workload using its StampedLock optimistic read idiom. VarHandle field-replacement with VarHandle CAS matches Unsafe speeds once warmed. Phaser party limit is 65k but can be tiered into a tree.
AI-written summary · about
chapters (16)
- 0:00Introduction and speakers
- 2:39About the speakers
- 5:29Code joining approaches overview
- 10:44Demo wait notify approach
- 19:33Demo reentrant lock approach
- 23:02Demo countdown latch approach
- 26:10Demo volatile spin approach
- 28:00Demo phaser approach
- 38:17StampedLock introduction
- 48:49Crocodile synchronization demo
- 54:03Demo reentrant lock vs synchronized
- 57:37Demo reentrant read-write lock
- 59:00Demo StampedLock approach
- 1:05:15VarHandle introduction
- 1:07:03Demo VarHandle approach
- 1:12:06Closing and Q&A
related talks
51mThread Safety with Phaser, StampedLock and VarHandle
52mThread Safety with Phaser, StampedLock and VarHandle.
47mThread Safety with Phaser, StampedLock, and VarHandle
47mUsing Java 8 Lambdas and Stampedlock to manage thread safety
01h 06mLocks are tricky — let's understand them by building one
01h 02mMaking Games Start Fast: A Story About Concurrency
45mThe Hidden Art of Thread-Safe Programming: Exploring java.util.concurrent
01h 04mAtomics, Locks, and Tasks (part 2 of 2)
