I've been searching in some places on the internet but I have not found any coherence in the definitions given on the subject of thread in Java.
What are the possible states of a thread and what are its definitions.
I've been searching in some places on the internet but I have not found any coherence in the definitions given on the subject of thread in Java.
What are the possible states of a thread and what are its definitions.
Imagetakenfrom Thread States and Life Cycle .
States, according to documentation are: / p>
thread
is created, however, they did not invoke start()
in the reference. start()
was invoked in the reference. BLOCKED :
thread
is considered in the BLOCKED state when waiting for data. thread
is also considered BLOCKED when waiting for Lock
of another thread. thread
that is waiting indefinitely for another thread to perform a given action is in this state. thread
that is waiting for another thread to perform an action for up to a specified timeout is in this state.
TERMINATED : A thread
that has gone out is in this state.
To know the states, in Java
you can use the Thread.getState
method that returns:
What's more, you can call isAlive()
TRUE
means that the thread is in the Runnable state or the Non-Runnable state.
References:
If it is specific to Java it is easy to find out that states are defined by an enumeration, so everyone has documentation of Thread.State
.
start()
) RUNNING
) Lock
or some IO operation DEAD
) It will not vary much from this, but other implementations may use another set of states.
Note that the inconsistencies found are probably because people are talking about different things. I get the documentation, certainly not wrong. When you find inconsistency always go in what is official.
If you are not talking about Java the states may vary. Each platform can have its own control, even different from the operating system. If you're curious, check out threads in> possible in C # .