JavaIntermediate#concurrency

Explain multithreading and the Thread lifecycle.

States: New, Runnable, Running, Blocked/Waiting, Timed Waiting, Terminated. Create threads by extending Thread or implementing Runnable/Callable. Prefer ExecutorService for production code.

Example
Thread t = new Thread(() -> System.out.println("running"));
t.start(); // New -> Runnable -> Running -> Terminated

Related Questions

1
JavaAdvanced#concurrency

Difference between synchronized and volatile?

Open
2
JavaAdvanced#concurrency

What is the Executor framework?

Open
3
JavaIntermediate#concurrency

What is the difference between Callable and Runnable?

Open