Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Threads sleep/yield

  Asked By: Pedro    Date: Jul 03    Category: Java    Views: 885

I just wanted to get verification.
When Thread.sleep is called - does it pass execution to other
threads? or does it hold execution

Meaning, when a thread is sleeping, are other threads executing? Or
does the thread hold execution for its 'share'



3 Answers Found

Answer #1    Answered By: Mehreen Malik     Answered On: Jul 03

If the other thread  is called  before the sleep method then the other
thread will continue processing. But if you have



then methody() will be called after the sleeping has finished.

Answer #2    Answered By: Daya Sharma     Answered On: Jul 03

Yes, it passes execution  to other threads..........

Answer #3    Answered By: Viren Rajput     Answered On: Jul 03

This question is not entirely meaningful.
Java threads  are always pre-emptive.
Even if the thread  didn't pass  execution,
other threads would still be executing
and get their share  of the CPU - so you don't
have to worry about it.

Didn't find what you were looking for? Find more on Threads sleep/yield Or get search suggestion and latest updates.