Results 1 to 2 of 2

Thread: Thread

  1. #1
    parimalakr is offline Member
    Join Date
    Jun 2010
    Posts
    4
    Rep Power
    0

    Default Thread

    Hi

    Wat's the difference between sleep() of thread class and wait() of Object.


    Thanks

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by parimalakr View Post
    Wat's the difference between sleep() of thread class and wait() of Object.
    first of all wait() must be called within a synchronized block, sleep() not. with wait() the object is putted into the wait-pool monitor and must wait for a notify() or notifyAll() to get a change for running again. sleep() goes into a non-runnable state after the method sleep() is called a turn back into the state runnable at earlies when the given milliseconds are elapsed.
    Last edited by j2me64; 06-14-2010 at 04:11 PM.

Similar Threads

  1. Difference between Thread.yield() and Thread.sleep() methods
    By Nageswara Rao Mothukuri in forum New To Java
    Replies: 12
    Last Post: 07-30-2010, 05:37 PM
  2. Trigger main thread method from secondary thread?
    By DigitalMan in forum Threads and Synchronization
    Replies: 8
    Last Post: 01-26-2010, 02:13 AM
  3. passing a value from parent thread to child thread
    By sachinj13 in forum Threads and Synchronization
    Replies: 7
    Last Post: 09-07-2008, 09:06 PM
  4. Replies: 0
    Last Post: 01-28-2008, 07:02 AM

Posting Permissions

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