What Is a Thread in Java — Thread, Runnable, and Multithreading Explained
Fast recall
Quick revision
Core answer
ExecutorService) or extending Thread (legacy). Multithreading pays off for three workloads: CPU-bound parallelism (dividing work across cores), I/O concurrency (overlapping waits), and responsiveness (keeping UI/event loops free). As of Java 21, virtual threads (Project Loom) give you millions of cheap, JVM-scheduled threads ideal for I/O-bound servers.Whether the candidate has a mental model of threads as independent execution paths sharing memory, understands `Thread` vs `Runnable`, and can articulate why concurrency matters
Thinking threads have separate memory — they share heap. Calling `thread.run()` instead of `thread.start()` and wondering why everything runs on the main thread
Mention 1:1 OS thread mapping, the ~1 MB stack cost per platform thread, `ExecutorService` as the modern way to create them, and Java 21 virtual threads for I/O-bound workloads
Interview-ready guide
Interview answer
A thread is an independent execution path inside one JVM process.
What's isolated per thread
- Stack (local variables, call frames)
- Program counter
ThreadLocalvalues
What's shared
- The heap — all objects allocated with
new - Method area, loaded classes, static fields
- File descriptors and system resources
This shared-heap model is the core of both power and danger
- Power: passing data between threads is free — share an object reference
- Danger: uncoordinated reads and writes cause race conditions and visibility bugs
On mainstream JVMs, platform threads are 1:1 with OS threads
pthread_createon Linux,CreateThreadon Windows- ~512 KB to 1 MB of stack per thread (tunable with
-Xss) - Practical limit: 5,000–10,000 platform threads per server
- The OS scheduler, not the JVM, decides when each runs
Three ways to create threads
- Extend `Thread` — legacy; wastes single inheritance slot
- Implement `Runnable` — preferred; functional interface so lambdas work; decouples task from thread
- `ExecutorService` — the modern default; submit
RunnableorCallabletasks to a pool - `Callable
` isRunnableplus return value and checked-exception support
When multithreading actually helps
- CPU-bound parallelism — dividing work across cores (up to Amdahl's limit)
- I/O concurrency — overlapping slow network or disk waits
- Responsiveness — keeping UI or event loops free while background work runs
Java 21 virtual threads changed everything for I/O workloads
- M:N scheduled — JVM multiplexes millions of virtual threads on a small platform-thread carrier pool
- When a virtual thread blocks on I/O, it unmounts from its carrier cheaply
Executors.newVirtualThreadPerTaskExecutor()is the idiom- Use for I/O-bound servers; avoid for CPU-bound work or code with
synchronizedon long I/O (pinning problem)
Recommendation: In modern code, don't call new Thread(...) directly. Reach for ExecutorService for bounded pools on CPU work, or Executors.newVirtualThreadPerTaskExecutor() on Java 21+ for I/O-bound request handling. Always prefer Runnable or Callable over extending Thread. Remember that the heap is shared — any mutable state accessed from multiple threads needs coordination via synchronized, java.util.concurrent, or immutability.
What Is a Thread in Java — `Thread`, `Runnable`, and Multithreading Explained
Direct Answer
A thread is an independent path of execution within a JVM process, sharing heap memory but having its own stack and program counter. Java threads are 1:1 mapped to OS native threads on all mainstream JVMs (HotSpot, OpenJ9) — each platform thread costs ~0.5–1 MB of stack memory and is scheduled by the OS. You create them by implementing Runnable (preferred — preserves your single inheritance slot and works with ExecutorService) or extending Thread (legacy). Multithreading pays off for three workloads: CPU-bound parallelism (dividing work across cores), I/O concurrency (overlapping waits), and responsiveness (keeping UI/event loops free). As of Java 21, virtual threads (Project Loom) give you millions of cheap, JVM-scheduled threads ideal for I/O-bound servers.
Common Mistakes & Pitfalls
Thinking threads have separate memory — they share heap. Calling thread.run() instead of thread.start() and wondering why everything runs on the main thread
Check your understanding
Answer these without looking back at the article.
- How are Java threads scheduled — by the JVM or the OS?
- What's the default stack size of a Java thread and how do you change it?
- How does `ThreadLocal` survive while being thread-private?
- When would a virtual thread be worse than a platform thread?
- What's the difference between `Runnable` and `Callable`?
Related interview prep categories
2Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.