The Java Memory Model
The rules that decide when a write by one thread becomes visible to another, expressed as the happens-before relationship.
Threads and concurrency utilities.
9 notes tagged
The rules that decide when a write by one thread becomes visible to another, expressed as the happens-before relationship.
Purpose built collections for shared access, which are both safer and far faster than wrapping an ordinary one in a lock.
A Future is a placeholder for a result that is not ready yet. CompletableFuture adds composition, so results can be chained without blocking.
An executor separates submitting work from running it, so threads are reused instead of created per task.
The two failures that define concurrency: results that depend on timing, and threads that wait for each other forever.
Explicit locks offer timeouts, fairness and multiple conditions, and the atomic classes give lock free updates for single variables.
synchronized gives mutual exclusion and visibility. volatile gives visibility only, and knowing the difference prevents most concurrency bugs.
A thread moves through six states, and knowing which one it is in is the first step in diagnosing any hang.
A thread is an independent path of execution inside one process, and Java gives you several ways to start one.