Introduction
- One Java program = one process
- A process can have many threads (doing different execution**)**
- Threads share:
- Heap memory
- Static variables
- Threads have their own:
Process (JVM)
├─ Thread A
├─ Thread B
└─ Thread C
Platform Threads (Traditional)
- Backed by OS threads (1 Java thread = 1 OS Thread)
- Heavy (~1MB stack per thread)
- Limited (~thousands max)
- Context switching is expensive
- Each blocked thread = wasted OS thread
new Thread(() -> {}).start();
Thread lifecycle
start() → creates new thread
run() → task logic (DO NOT call directly)
sleep(ms) → pause