A Thread can be in one of the 5 states :
– Thread instance has been created, but start() method has not been invoked on the thread.
– The thread is not alive at this state.
– The thread is eligible to run, but scheduler hasn’t selected it to be the running thread.
– A thread first goes to runnable state when the start() method is invoked, but it can again return to runnable after running or from a sleeping, blocking or waiting state.
– The thread is alive.
– A thread is in running state when the thread scheduler selects it to be the currently executing process.
– thread is alive, but not currently running or not in runnable state.. it can return to runnable state.
– A thread can go to sleep for some time if Thread.sleep() is called.
-thread may be blocked waiting for a resource.
– thread may be waiting because of some code.
– thread is still considered alive.
– a thread is dead after run() method completes.
– once its dead, it can not go back to runnable or running state again.
© 2015 – 2018, www.topjavatutorial.com. All rights reserved. On republishing this post, you must provide link to original post