Skip to content
UPEEC

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.

Advanced
Comments 0

This is an overview — pick a sub-topic below.

Sub-topics (14)

Thread Lifecycle

NEW → RUNNABLE → BLOCKED / WAITING / TIMED_WAITING → TERMINATED.

Easy♥ 0🔖 0💬 0

Thread Class

Create and control threads directly.

Easy♥ 0🔖 0💬 0

Runnable

A task with no result: `void run()`.

Beginner♥ 0🔖 0💬 0

Callable

A task that returns a result and may throw: `V call() throws Exception`.

Easy♥ 0🔖 0💬 0

ExecutorService

Thread pools that run submitted tasks.

Intermediate♥ 0🔖 0💬 0

ForkJoinPool

A work-stealing pool for recursive divide-and-conquer tasks (`RecursiveTask`).

Advanced♥ 0🔖 0💬 0

Synchronization

`synchronized` methods/blocks give mutual exclusion and visibility.

Intermediate♥ 0🔖 0💬 0

Locks in Java

`ReentrantLock`, `ReadWriteLock` and `StampedLock` offer timeouts, fairness and read/write separation.

Intermediate♥ 0🔖 0💬 0

volatile in Java

Guarantees visibility of writes to other threads (and ordering), but not atomicity.

Intermediate♥ 0🔖 0💬 0

Atomic Classes

Lock-free thread-safe variables: `AtomicInteger`, `AtomicLong`, `AtomicReference`, `LongAdder`.

Intermediate♥ 0🔖 0💬 0

Concurrent Collections

Thread-safe collections: `ConcurrentHashMap`, `CopyOnWriteArrayList`, `BlockingQueue`, `ConcurrentLinkedQueue`.

Intermediate♥ 0🔖 0💬 0

CompletableFuture

Compose asynchronous operations without blocking.

Advanced♥ 0🔖 0💬 0

Virtual Threads

Lightweight JVM-managed threads (Java 21) — millions of concurrent blocking tasks.

Intermediate♥ 0🔖 0💬 0

Java Memory Model

Defines when writes by one thread become visible to others via "happens-before" relationships.

Expert♥ 0🔖 0💬 0

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.