Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, the state you describe with <code>READY TO RUN</code> is actually <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.State.html#RUNNABLE" rel="noreferrer">RUNNABLE</a>. For my bachelor thesis I had created a transition graph showing the different thread states and when they ought to change. You haven't described the semantics of <code>getIn()</code>, so I guess it is just a random method.</p> <p>If the thread is executing code, for instance on of your methods <code>getIn()</code> or <code>getOut()</code> it is <code>RUNNABLE</code> and not <code>WAITING</code>. <code>BLOCKED</code> is actually only a very short transition state, which is always entered when a thread tries to claim a lock. If the lock is not available the thread keeps being blocked and cannot execute another action as you imply in step 6. Also it cannot invoke a method after calling <code>Thread.sleep()</code> it has to wait, until the time is elapsed.</p> <p>I would correct it the following way:</p> <ol> <li><code>RUNNABLE</code></li> <li><code>TIMED WAITING</code></li> <li><code>RUNNABLE</code></li> <li><code>BLOCKED</code></li> <li><code>TIMED WAITING</code></li> <li><code>BLOCKED</code></li> <li><code>RUNNABLE</code></li> <li><code>TERMINATED</code></li> </ol> <p><img src="https://i.stack.imgur.com/n2U3N.png" alt="Thread State Transitions"></p> <p>Disclaimer: There is no guarantee for the transitions. It might even be, that a JVM vendor decides to implement the underlying mechanics in another way, for instance it could implementing blocking by spin-waiting.</p> <p>If you want to dive deeper into this topic use a Profiler to find out the states of your thread. I have written one of my own to detect those states: <a href="https://github.com/platzhirsch/java-concurrency-profiler" rel="noreferrer">Java Concurrency Profiler</a>, but there are others out there as well, for instance <strong>VisualVM</strong> or <strong>YourKit</strong>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload