38. Briefly explain high-level thread states


The state chart diagram below describes the thread states.


  • Runnable — waiting for its turn to be picked for execution by the thread schedular based on thread priorities.
  • Running: The processor is actively executing the thread code. It runs until it becomes blocked, or voluntarily gives up its turn with this static method Thread.yield(). Because of context switching overhead, yield() should not be used very frequently.
  • Waiting: A thread is in a blocked state while it waits for some external processing such as file I/O to finish.
  • Sleeping: Java threads are forcibly put to sleep (suspended) with this overloaded method: Thread.sleep(milliseconds), Thread.sleep(milliseconds, nanoseconds);
  • Blocked on I/O: Will move to runnable after I/O condition like reading bytes of data etc changes.
  • Blocked on synchronization: Will move to Runnable when a lock is acquired.
  • Dead: The thread is finished working.


1 comment:

  1. We drаmatіc mагket sωings on an аlmost daіlу basis.
    60% annual increase in EPS since 2001. Data mining DM creates information assets make fish an organization can possess brilliant ideas for company growth by describing how the growth could take place. Personnel - The total variety of personnel that you deal with your current customers and acquire new purchasers is as a result of referrals.

    Feel free to surf to my web blog ... Http://Mcdipper.Com

    ReplyDelete