when does a thread reach the terminated status? Does it get terminated when the end of the run()
method is reached?
So what is the right wa
First: Thread.getState() returns a Thread.State, which will never be equal to a String
, so you'd need to write that code like this:
if(thread.getState()!=Thread.State.TERMINATED){ }
And yes: when the run()
method ends (either normally or because it throws an exception), then a Thread
will go to the TERMINATED state.