~/talk

Using Java 8 Lambdas and StampedLock To Manage Thread Safety

Talkat Devoxx UK 2017 · 2017-05-11..05-12· [java, concurrency]
links:none on file
slides:none on file

Claim: StampedLock optimistic reads let readers proceed without blocking writers, upgrade reads to writes (tryConvert), and often outperform ReentrantReadWriteLock for multi-field invariants; drawback: not reentrant and validate can force fallback to a pessimistic read. Demo: converting a primitive Trove map to use StampedLock yields much higher throughput. Alternatives shown: nonblocking AtomicReference/compare-and-swap, Unsafe, and VarHandles as safe Unsafe alternative (Java 9 compareAndExchange returns prior value but can be slower under high contention). Lambdas make lock idioms pluggable but checked exceptions complicate use.

AI-written summary · about

  1. 0:00Introduction to talk
  2. 1:06What is StampedLock
  3. 3:57StampedLock advantages
  4. 8:59Crocodile analogy for invariants
  5. 10:01Pessimistic read with StampedLock
  6. 11:24Optimistic read validation
  7. 15:36Value holder objects approach
  8. 19:57AtomicReferenceFieldUpdater
  9. 23:50Why avoid Unsafe
  10. 25:19VarHandles introduction
  11. 27:05Compare-and-exchange in Java 9
  12. 31:03Conditional read-to-write upgrade
  13. 32:58StampedLock vs synchronized
  14. 37:17AutoCloseable locks and lambdas
  15. 41:10Lambda checked exceptions issue
  16. 44:21Lambda idioms for concurrency
  17. 46:50Future of concurrency patterns
  18. 48:34Synchronized vs ReentrantLock
  19. 50:00When to use StampedLock
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.