Skip to content
Veltoryx Technologies
ProLesson 14.4Advanced3 min readUpdated 30 October 2026

Concurrency interview questions

Threads, synchronized, volatile, executors, CompletableFuture, deadlocks and virtual threads, as interviewers ask them.

Concurrency questions separate junior from senior candidates. Clear definitions plus one practical example each will set you apart.

01Must-know answers

1. Process vs thread? A process has its own memory; threads within a process share the heap and each has its own stack. (9.1)

2. start() vs run()? start() creates a new thread that calls run(); calling run() directly runs on the current thread. (9.2)

3. What are the thread states? NEW, RUNNABLE, BLOCKED (waiting for a monitor), WAITING, TIMED_WAITING and TERMINATED. (9.2)

4. What is a race condition? A result that depends on thread timing, like lost updates from count++ (read–modify–write). Fix it with synchronized, locks or atomics. (9.3)

5. What does synchronized guarantee? Mutual exclusion on a monitor, plus visibility of changes to the next thread that takes the same lock. It's reentrant. (9.3)

6. What does volatile do, and not do? It guarantees visibility and ordering for one variable, but not atomicity: count++ is still unsafe. Use it for flags. (9.4)

7. wait() vs sleep()? wait releases the monitor and needs to hold it; sleep keeps all locks. Call wait in a loop. (9.5)

8. synchronized vs ReentrantLock? Both are mutual and reentrant. A lock adds tryLock, timeouts, interruptibility, fairness and multiple conditions, but you must unlock in finally. (9.6)

9. Why use thread pools? How does ThreadPoolExecutor decide? To reuse threads and bound concurrency. Below core size it adds a thread; otherwise it queues; with the queue full it grows to the maximum; at the maximum it applies the rejection policy. (9.7)

10. Future vs CompletableFuture? Future only lets you block, poll or cancel; CompletableFuture chains, combines, handles errors and supports timeouts without blocking. (9.8)

11. How does ConcurrentHashMap achieve thread safety? Lock-free reads, CAS and per-bucket locks for writes, and atomic compute and merge. No nulls; iterators are weakly consistent. (9.9)

12. How do atomic classes work? Compare-and-set in a retry loop: lock-free. LongAdder is better for hot counters. Watch for the ABA problem. (9.10)

13. What causes deadlock, and how do you prevent it? Mutual exclusion, hold and wait, no preemption, circular wait. Lock in a consistent order, use tryLock with timeouts, and keep locks small. Diagnose with a thread dump. (9.11)

14. What are virtual threads? JVM-managed lightweight threads (Java 21) that unmount from carrier threads when blocked, so you can have millions. Use them for I/O-bound work; don't pool them; watch for pinning. (9.12)

15. How would you make a class thread-safe? In order of preference: make it immutable; confine state to one thread; use concurrent collections and atomics; and only then add locks around compound operations.

Loading the rest of the lesson…