Java Concurrency
Threads, executors, synchronisation, atomics, concurrent collections, async programming, virtual threads and the memory model. Multithreading basics have their own page earlier in this subject.
This is an overview — pick a sub-topic below.
Sub-topics (14)
Thread Lifecycle
NEW → RUNNABLE → BLOCKED / WAITING / TIMED_WAITING → TERMINATED.
Thread Class
Create and control threads directly.
Runnable
A task with no result: `void run()`.
Callable
A task that returns a result and may throw: `V call() throws Exception`.
ExecutorService
Thread pools that run submitted tasks.
ForkJoinPool
A work-stealing pool for recursive divide-and-conquer tasks (`RecursiveTask`).
Synchronization
`synchronized` methods/blocks give mutual exclusion and visibility.
Locks in Java
`ReentrantLock`, `ReadWriteLock` and `StampedLock` offer timeouts, fairness and read/write separation.
volatile in Java
Guarantees visibility of writes to other threads (and ordering), but not atomicity.
Atomic Classes
Lock-free thread-safe variables: `AtomicInteger`, `AtomicLong`, `AtomicReference`, `LongAdder`.
Concurrent Collections
Thread-safe collections: `ConcurrentHashMap`, `CopyOnWriteArrayList`, `BlockingQueue`, `ConcurrentLinkedQueue`.
CompletableFuture
Compose asynchronous operations without blocking.
Virtual Threads
Lightweight JVM-managed threads (Java 21) — millions of concurrent blocking tasks.
Java Memory Model
Defines when writes by one thread become visible to others via "happens-before" relationships.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.