Java thread state

I have a question, how is the state of the thread when it is created. And this variant has both a ready-made and an executable file. So my doubts are:

  • Is there a state whose state is called ready?
  • If so, is there a difference between the current and ready state of the thread?
  • If so, what would be the appropriate answer?

Thanks in advance.

+3


source to share


3 answers


1 - no, it's NEW

2 - NEW awaits execution, RUNNABLE executes



3 - NEW

Who could answer better than Oracle: https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.State.html

+2


source


In fact, starting and executing a thread implies collaboration between the JVM and the OS. The JVM makes a call to the underlying OS. The states that you refer to as ready is the state where a thread is waiting for a set of threads. This means that the thread is ready to run and the thread scheduler can schedule it.

Don't mix OS and Java level states. From a Java perspective, there are only 5 states



1. New
2. Runnable
3. Waiting
4. Timed Waiting
5. Terminated

      

+1


source


Here is a java thread state machine:

enter image description here

+1


source







All Articles