Concurrency
Threads and the state they share: Thread with a Runnable and the difference between start and run, a lost update measured on a real run and the synchronized that fixes it. ExecutorService pools the work, Callable and Future return a result and a failure, atomics count without a lock, and ReentrantLock locks and unlocks in a finally. The concurrent collections follow, with a producer and a consumer on a BlockingQueue, then CompletableFuture, and virtual threads, which run many tasks on the carriers. The capstone counts words in parallel and checks the total against one thread.
10.1
Threads
Thread, Runnable, start against run, join, the main thread
Open
10.2
Shared state and synchronized
a lost update measured, synchronized, the same count after the fix
Open
10.3
ExecutorService
newFixedThreadPool, submit, invokeAll, shutdown, awaitTermination
Open
10.4
Callable and Future
a result from a task, get, a timeout, ExecutionException
Open
10.5
Atomics
AtomicInteger, incrementAndGet, compareAndSet, LongAdder
Open
10.6
ReentrantLock
lock and unlock, tryLock, Condition, the finally that unlocks
Open
10.7
Concurrent collections
ConcurrentHashMap, BlockingQueue, a producer and a consumer
Open
10.8
CompletableFuture
supplyAsync, thenApply, thenCombine, allOf, join
Open
10.9
Virtual threads
Thread.ofVirtual, newVirtualThreadPerTaskExecutor, a measured run of many tasks
Open
10.10
Capstone: a parallel word count
files, an executor, a ConcurrentHashMap, the result checked against one thread
Open