Results 1 to 5 of 5

Thread: What is the difference between wait and sleep method in java ?

  1. #1
    Registered
    Join Date
    May 2016
    Posts
    39

    What is the difference between wait and sleep method in java ?

    what is the difference between wait and sleep method in java?

  2. #2
    Thoughtgrid Thoughtgrid's Avatar
    Join Date
    Jul 2016
    Location
    Bangalore
    Posts
    219
    sleep():
    It is an static method in thread class it make current thread into "Not Runnable"state for specific amount of time.
    wait():
    It is a method on object class make the current thread into "Not Runnable"state it is called on object not thread.

  3. #3
    The fundamental difference is wait() is from Object and sleep() is static method of Thread . The major difference is that wait() releases the lock while sleep() doesn't releas any lock while waiting. The wait() is used for inter-thread communication while sleep() is used to introduce pause on execution, generally.

  4. #4

  5. #5
    Registered pxljobs's Avatar
    Join Date
    Jul 2016
    Location
    Bangalore
    Posts
    290
    In sleep() methods used to hold the process for few seconds
    In wait() methods thread go to waiting state not come back automatically until call (notify,notify all) methods

Similar Threads

  1. What are the Difference between SMO and PPC
    By Nexevo Technologi in forum Search Engine Optimization
    Replies: 0
    Last Post: 12-01-2015, 05:10 AM
  2. [SHARE]Degustation, X Rays, Winter Sleep Blogger Themes
    By silverf0x in forum The Marketplace
    Replies: 0
    Last Post: 03-02-2011, 03:27 PM
  3. Sleep
    By moonshield in forum General Chat
    Replies: 18
    Last Post: 02-15-2007, 03:27 AM
  4. Inability to sleep?
    By Fender963 in forum General Chat
    Replies: 22
    Last Post: 03-31-2006, 04:56 AM
  5. GO ON BACK TO SLEEP Touch Support 24/7/365 50% Off
    By TSGradyR in forum The Marketplace
    Replies: 0
    Last Post: 11-08-2005, 04:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

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