submit() returns a Future to get the result later| Platform Thread | Virtual Thread | |
|---|---|---|
| Managed by | Operating System | JVM (lightweight) |
| Cost to create | Relatively expensive | Very cheap |
| Typical count | Hundreds to low thousands | Millions possible |
Treats a group of related subtasks running on their own threads as a single unit of work — if one subtask fails, the others are cleanly cancelled together, instead of leaking loose threads.
A modern, safer alternative to ThreadLocal for sharing immutable data down a call chain — automatically cleaned up when the scope ends.
When multiple threads update shared data at once, updates can be lost ("race conditions"). The synchronized keyword (or explicit Lock objects) ensures only one thread executes the critical section at a time.
A fixed-capacity, thread-safe queue that automatically pauses producers when full and consumers when empty — no manual wait()/notify() needed.
JavaFX UI updates must happen on the JavaFX Application Thread only. For long-running work, run it on a background thread and push UI updates back safely: