wait and sleep difference?

wait and sleep difference?

  • For sleep () method of the Thread class belongs. And wait () method, Object belongs to the class.
  • sleep () method results in a program to suspend the specified time, so that the cpu to other threads, but his remains were monitoring state, when the specified time is up will automatically resume operation.
  • During the call to sleep () method, the thread will not release the object lock.
  • And when the call wait () method, the thread will give up the object lock, into the waiting for this object to wait for the lock pool, only after calling notify for this object () method of the thread before entering the locked object pool ready to acquire the object lock into operation.

Guess you like

Origin www.cnblogs.com/fly-book/p/11446115.html