Java并发编程--yield sleep和wait的区别

JDK version: 1.8

其中 yield(), sleep(long millis) 是 java.lang.Thread 的类方法.

wait() 是 java.lang.Object 的实例方法.

Thread.yield()

A hint to the scheduler that the current thread is willing to yield its current use of a processor. The scheduler is free to ignore this hint.

Thread.sleep(long millis)

Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers. The thread does not lose ownership of any monitors.

Object.wait()

详见: Java并发编程--wait/notify/notifyAll 方法的使用

原文地址:https://www.cnblogs.com/xxoome/p/13825323.html