Results 1 to 2 of 2
  1. #1
    Leon945 is offline Member
    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Default Thread.sleep() help, how does it decide which thread to sleep?

    Hello,

    I've recently discovered (not really proud of it) that the sleep() method in the Thread class is a static method.
    Knowing that fact now, the question I have is, how does this class decide which running thread to sleep?

    I've used it before and it always seems to sleep the one i want, but how can i be sure if this is a static method and only the parameter of time is sent to it.

    thanks in advance.

  2. #2
    sabre150 is offline Member
    Join Date
    Jul 2012
    Location
    Earth
    Posts
    75
    Rep Power
    0

    Default Re: Thread.sleep() help, how does it decide which thread to sleep?

    Whatever Thread you execute the Thread.sleep() method in is the one that sleeps.

Similar Threads

  1. Thread.sleep
    By Gog in forum New To Java
    Replies: 3
    Last Post: 01-13-2011, 09:14 AM
  2. Difference between Thread.yield() and Thread.sleep() methods
    By Nageswara Rao Mothukuri in forum New To Java
    Replies: 12
    Last Post: 07-30-2010, 06:37 PM
  3. how to reduce the thread sleep time and wake up the thread
    By baktha.thalapathy in forum Threads and Synchronization
    Replies: 2
    Last Post: 06-24-2010, 08:36 PM
  4. Sleep in thread
    By jithan in forum New To Java
    Replies: 1
    Last Post: 08-27-2008, 03:27 PM
  5. Can't get my thread to sleep!
    By jamesfrize in forum New To Java
    Replies: 2
    Last Post: 03-25-2008, 06:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •