A thread can have many states during its lifetime.
In this lesson, you will monitor the state of a threat during its lifetime.
The state of a threat can be new, which means the threat hasn't started executing it.
So if we print the thread state before we start it, system data, print line threat to get state.
It should return a state of new.
Now, the state of a thread can also be runnable, which means the thread is currently running.
If we print the thread states right after starting it.
It's still running.
And now it finishes.
Now, the state of a threat can also be terminated, which means the threat is finished.
The problem is we're printing the state of the background thread from inside the main thread.
So if we run our current code?
The main thread finishes executing while our background thread is still running.
But what if we put this here?
We should get the same thing because the time it takes to go from here to here is zero milliseconds.
But this task takes three seconds to execute.
From a visual perspective, we're making progress on both threads at the same time.
But the main thread finishes way before the second thread, so given our current knowledge about threads,
it would be really hard to print a terminated state for threat to.
But don't worry, we're going to revisit this.
Let's recap, a threat can have many states during its lifetime.
We looked at the new state, which means a threat hasn't started yet.
A runnable state, which means the threat is still running and terminated, which means the threat is
finished.
A thread can have other states, but for now we're just going to focus on these.