首页 > 编程语言 > 详细

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

时间:2020-10-16 12:04:56      阅读:30      评论:0      收藏:0      [点我收藏+]

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 方法的使用

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!