Handling concurrent access to shared resources in Java
summary
Shows concrete Java fixes: a flaky library/book-rental demo that sometimes gives the same book to two threads, fixed by synchronizing on the book and then broken again when a synchronized method plus wait/notify causes a deadlock. Covers synchronized, ReentrantLock, ReentrantReadWriteLock, volatile semantics, and advice to unlock in finally. Notes virtual threads still use carrier threads and synchronized pins carrier threads so prefer explicit locks. Discusses distributed strategies, optimistic vs pessimistic locking, and Spring Integration for DB-backed distributed locks.
AI-written summary · about
chapters (12)
- 0:00Introduction and speaker intro
- 3:38What is concurrency in Java
- 7:36Levels of concurrency in Java
- 10:08Shared resources and race conditions
- 16:17Solving race conditions with synchronization
- 20:13Synchronized blocks and methods
- 25:19Demo: Library book rental race condition
- 30:32Using locks for concurrency control
- 33:04Read-write locks explained
- 35:12Virtual threads and synchronization
- 37:25Concurrency in distributed systems
- 39:54Q&A on concurrency challenges
related talks
45mThe Hidden Art of Thread-Safe Programming: Exploring java.util.concurrent
41mEverything You Don’t Want to Know About Concurrency on the JVM
50mThe Hidden Art of Thread-Safe Programming: Exploring java.util.con...
47mUsing Java 8 Lambdas and Stampedlock to manage thread safety
52mSTM and Structured Concurrency — The Battle with Multithreading Dragons
48mHow to build distributed concurrency primitives
01h 14mMultithreading in UI application: When some threads are more equal than others
39mLet's talk concurrency
