Difference between wait() and sleep()

前端 未结 30 3185
無奈伤痛
無奈伤痛 2020-11-22 00:24

What is the difference between a wait() and sleep() in Threads?

Is my understanding that a wait()-ing Thread is still in runni

30条回答
  •  后悔当初
    2020-11-22 00:45

    Wait and sleep are two different things:

    • In sleep() the thread stops working for the specified duration.
    • In wait() the thread stops working until the object being waited-on is notified, generally by other threads.

提交回复
热议问题