SLIDE 1
1
1
Java threads: synchronization
2
Thread states
- 1. New:
- created with the new operator (not yet started)
- 2. Runnable:
- either running or ready to run
- 3. Blocked:
- deactivated to wait for something
- 4. Dead:
- has executed its run method to completion, or
terminated by an uncaught exception
- a started thread is executed in its own run-time
context consisting of: program counter, call stack, and some working memory (registers, cache)
3
Thread states
4
Thread states (cont.)
- don't confuse the interface java.lang.Runnable with
the state Runnable
- "running" is not a separate state within Runnable, but
Thread.currentThread () // static method identifies the current thread object (for itself)
- thread.isAlive () tells if the thread has been started (is