ReviseAlgo Logo

Multithreading

24 Topics
1

Threads Basics

Understand process vs thread, thread schedulers, thread safety overview, and basic concurrency concepts.

Tests fundamental execution models: difference between processes and threads, shared memory layout, context switching, and CPU cores mapping.
2

Creating Threads

Learn to subclass the Thread class vs implementing the Runnable interface with modern lambda expressions.

Frequently tests the architectural pros and cons of implementing Runnable vs extending Thread, including flexibility and object-oriented design.
3

Thread Lifecycle

Understand the different states of a Java thread and transitions between them.

Deeply tests understanding of the JVM thread state diagram (NEW, RUNNABLE, WAITING, TIMED_WAITING, BLOCKED, TERMINATED).
4

Thread Methods

Deep dive into core thread methods: start(), run(), sleep(), join(), yield(), and interrupt().

Commonly tests how to properly manage thread execution and handle the InterruptedException properly.
5

Thread Priority

Understand thread priority, daemon threads, and their impact on application lifecycle.

Focuses on daemon thread rules (JVM shutdown behavior) and the pitfalls of relying on Thread Priorities.
6

Synchronization

Understand thread interference, critical sections, race conditions, and monitor locks.

Heavily tested on the mechanics of critical sections, how race conditions happen, and the Java monitor lock concept.
7

Synchronized Methods

Understand instance-level synchronized methods and how they lock on the object instance.

Commonly tests how synchronized instance methods coordinate locks, and what happens when multiple threads call different synchronized methods on the same object.
8

Synchronized Blocks

Learn to use block-level synchronization for fine-grained locking and better performance.

Commonly tests how to reduce locking overhead by shrinking lock scope, and how to lock on custom lock objects.
9

Static Synchronization

Understand class-level locks and the differences between static and instance synchronization.

Commonly tests the difference between instance-level locking and class-level locking in mixed contexts.
10

Inter-Thread Communication

Coordinate threads using wait(), notify(), and notifyAll() inside synchronized blocks.

Frequently tested through practical synchronization challenges, such as implementing a thread-safe Producer-Consumer pattern or Bounded Queue.
11

Deadlock

Understand deadlock conditions (Coffman conditions), prevention techniques, and thread dump analysis.

Commonly tested by asking you to write a deadlock scenario and then rewrite it to resolve the deadlock, or explain how to prevent it.
12

Thread Pool

Understand thread reuse, worker threads, and task queue configurations.

Tests understanding of thread pools, and the advantages of thread pools over raw thread creation.
13

ExecutorService

Understand the Java Executor framework, standard thread pool types, and configurations.

Heavily tested on ThreadPoolExecutor configuration parameters (corePoolSize, maxPoolSize, keepAliveTime, workQueue, and rejection policies).
14

Callable and Future

Submit tasks that return values or throw exceptions using Callable, and track results via Future.

Commonly tests how Callable differs from Runnable, how to handle execution exceptions, and Future.get() blocking behavior.
15

CompletableFuture

Write asynchronous, non-blocking pipeline operations with CompletableFuture.

Commonly tested on chaining operations (thenApply, thenAccept, thenCompose, thenCombine) and error handling.
16

Locks

Understand the Lock interface, ReentrantLock, lock timeouts, and fairness policies.

Tests comparison of Lock vs synchronized keyword, lock interruptibility, tryLock() usage, and unlocking best practices.
17

ReadWriteLock

Understand read-write separation locks and ReentrantReadWriteLock usage.

Focuses on write-exclusion vs read-sharing trade-offs, lock degradation/promotion rules.
18

Atomic Variables

Learn about lock-free, atomic operations using CPU Compare-And-Swap (CAS) instructions.

Focuses on Compare-And-Swap (CAS) theory, volatile fields inside Atomic variables, and comparing atomic classes vs synchronized performance.
19

volatile Keyword

Understand CPU caches, memory visibility, instruction reordering, and the volatile keyword.

Commonly tested on the distinction between memory visibility and atomicity, and when volatile is/isn't sufficient.
20

ThreadLocal

Provide thread-confined variables to isolate state within each individual thread.

Focuses on thread-confinement mechanics, use cases (database connections, transaction contexts), and preventing memory leaks in thread pools.
21

Semaphore

Manage resource pools using counting semaphores and throttling policies.

Commonly tested on counting permits, binary semaphores vs locks, and throttling concurrent resources.
22

CountDownLatch

Coordinate thread startup and synchronization using CountDownLatch.

Tests usage of CountDownLatch for starting multiple threads concurrently, and waiting for workers to complete.
23

CyclicBarrier

Coordinate cyclic, reusable barrier checkpoints in parallel algorithms.

Compares CyclicBarrier vs CountDownLatch and details how cyclic barriers run barrier actions.
24

Concurrency Best Practices

Write thread-safe code using immutable classes, thread-safe collections, and minimizing lock scope.

Commonly tested via design reviews: evaluate a block of code, identify concurrency bugs, and apply thread-safety optimizations.