Thread Safety with Phaser, StampedLock and VarHandle.
summary
Compares Phaser, StampedLock and VarHandle with microbench demos: measuring thread start jitter (volatile spin and countdown vs a phaser is a managed blocker), showing phaser achieves far tighter start alignment (examples show 27–42M start-coordination metrics) and supports ForkJoin/Loom but hits a 65k-party limit requiring hierarchical phasers for millions of virtual threads. Shows StampedLock’s optimistic read + validate cuts system-time from ~25% to ~3–5% in a position example, and a VarHandle array CAS variant gives high-throughput, lock-free updates.
AI-written summary · about
chapters (12)
- 0:00Introduction and setup
- 1:18Thread safety overview
- 2:58Phaser class explanation
- 4:20Wait-notify demo
- 10:37Countdown latch demo
- 13:28Volatile and spin locks
- 15:21Phaser performance demo
- 19:32StampedLock concepts
- 27:38StampedLock implementation
- 32:58Java 11 StampedLock idioms
- 44:15VarHandle demo
- 50:39Closing remarks
related talks
51mThread Safety with Phaser, StampedLock and VarHandle
01h 14mThread Safety with Phaser, StampedLock and VarHandle
47mThread Safety with Phaser, StampedLock, and VarHandle
47mUsing Java 8 Lambdas and Stampedlock to manage thread safety
01h 04mAtomics, Locks, and Tasks (part 2 of 2)
57mButcher Virtual Threads like a pro!
49mButcher Virtual Threads like a pro!
52mButcher Virtual Threads like a pro!
