Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

What is the fundamental difference between wait() and sleep() methods?

Pragya Keshap answered on February 4, 2023 Popularity 3/10 Helpfulness 1/10

Contents


More Related Answers

  • python wait 1 sec
  • wait function python
  • python code to wait
  • making a function wait in python
  • wait in python
  • Example For wait Method:
  • thread sleep() vs wait()
  • alternative to time.sleep() in python
  • What is sleep() method
  • thread sleep() vs wait()
  • Difference between sleep() and wait() in Java
  • Example For Sleep Method:
  • Java program to demonstrate the difference between wait and sleep
  • wait till value come
  • wait in python

  • What is the fundamental difference between wait() and sleep() methods?

    0

    The main difference between wait() and sleep() is that wait is an

    Object level method, whereas sleep() is a static method in Thread

    class. A waiting thread can be woken up by another thread by

    calling notify() on the monitor which is being waited on. But a

    sleeping thread cannot be woken up.

    A wait() and notify() has to happen within the same block that is

    synchronized on the monitor object.

    When we call wait() the current thread releases the monitor and

    goes to waiting state. Then another thread calls notify() to wake it

    up.

    In case of sleep() current thread does not release the monitor or

    locks. It just sleeps for some pre-defined time period.

    https://www.geeksforgeeks.org/difference-between-wait-and-sleep-in-java/

    Popularity 3/10 Helpfulness 1/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 04 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.