Results 1 to 4 of 4
  1. #1
    chathura87 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default Wait method and sleep method

    Hi all,

    I need to know what is the different between wait method and sleep method.. is the functionality of those 2 methods equivalent ?
    Specially wait(100) is one??? there is an overloaded method in wait we can pass a long value

    Thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Please have a look at what Google showed me:

    JGuru: sleep vs wait
    geekexplains: difference-between-sleep-and-wait

    You'll likely be able to find more decent explanations via Google if these don't offer satisfactory answers for you.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,457
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by chathura87 View Post
    Hi all,

    I need to know what is the different between wait method and sleep method.. is the functionality of those 2 methods equivalent ?
    Specially wait(100) is one??? there is an overloaded method in wait we can pass a long value

    Thanks
    Those methods are not equivalent; the sleep method just puts the current thread to sleep. The wait method needs an object (with an associated monitor) to make a tread wait. A waiting object can be notified (by another thread). Both methods can be interrupted. The wait method can have a timeout value.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    chathura87 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

Similar Threads

  1. Why would a String class need a wait() method?
    By javanb in forum New To Java
    Replies: 8
    Last Post: 12-06-2010, 01:36 PM
  2. Replies: 2
    Last Post: 03-26-2010, 05:12 PM
  3. How to use sleep() method
    By Hasan in forum Threads and Synchronization
    Replies: 12
    Last Post: 10-06-2009, 01:25 PM
  4. How to use sleep method of the Thread class
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-09-2008, 06:42 PM
  5. How to use sleep() to wait for a while
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-09-2008, 06:32 PM

Posting Permissions

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