Concurrency for Javas
Java concurrency is the set of tools for running work on multiple threads safely: Thread, Runnable, ExecutorService, CompletableFuture, locks and the synchronized keyword. It belongs to the Concurrency and JVM stage and focuses on avoiding race conditions, deadlocks and visibility bugs while using several CPU cores.
Stage: Concurrency and JVM · Part of the Java roadmap · Last reviewed 19 November 2026
What to learn in Concurrency
- Submit tasks to a fixed thread pool with ExecutorService and read results through Future
- Protect shared state using synchronized blocks or ReentrantLock
- Explain what volatile guarantees and what it does not
- Chain asynchronous steps with CompletableFuture
- Use ConcurrentHashMap and AtomicInteger instead of manual locking where possible
Concurrency interview questions
What is a race condition and how do you prevent it in Java?
A race condition occurs when the result depends on the timing of threads touching shared mutable data. Prevent it by avoiding shared state, using immutable objects, or guarding access with synchronized, locks or atomic classes so that updates happen one at a time.
What is the difference between synchronized and volatile?
synchronized gives mutual exclusion and also makes changes visible to other threads. volatile only guarantees visibility and ordering of reads and writes to one variable. It does not make compound actions such as count++ atomic, so it cannot replace a lock there.
Where Concurrency fits in the Java roadmap
Concurrency belongs to the Concurrency and JVM stage (intermediate level), which takes about 32 hours. Under the hood.