Skip to main content

9 docs tagged with "threads"

View all tags

Atomic Variables

Lock-free thread-safe operations using AtomicInteger, AtomicReference, LongAdder, and the compare-and-swap (CAS) CPU primitive that powers them.

java.util.concurrent

The high-level concurrency toolkit — ExecutorService, Future, CompletableFuture, CountDownLatch, CyclicBarrier, and Semaphore — that replaces manual thread management in production Java.

Locks

Explicit locking with ReentrantLock, ReadWriteLock, and StampedLock — when and why to reach for them over synchronized.

Multithreading & Concurrency Interview Questions

Consolidated interview Q&A for Java Multithreading — threads, synchronization, wait/notify, ExecutorService, locks, atomics, thread safety, and virtual threads from beginner through advanced.

Synchronization

How Java's synchronized keyword, intrinsic locks, volatile, and the happens-before relationship prevent race conditions in multithreaded programs.

Thread Safety Patterns

Three design-level strategies for writing correct concurrent code — immutability, ThreadLocal confinement, and explicit object confinement — without reaching for locks.

Threads & Lifecycle

What a Java thread is, how to create one, and the six lifecycle states a thread transitions through from creation to termination.

Virtual Threads (Java 21+)

Project Loom's virtual threads — how they work, how they remove the scalability ceiling of thread-per-request servers, and what pinning and structured concurrency mean for your code.

Wait / Notify

How Object.wait(), notify(), and notifyAll() coordinate threads using the intrinsic monitor — including the spurious wakeup rule and when to use each method.