thread - [多线程]Java中每个object的wait set是被谁操作的?
ringa_lee
ringa_lee 2017-04-18 10:25:32
[Java讨论组]

官方文档里有一段话:

Every object, in addition to having an associated monitor, has an associated wait set. A wait set is a set of threads.
When an object is first created, its wait set is empty. Elementary actions that add threads to and remove threads from wait sets are atomic. Wait sets are manipulated solely through the methods Object.wait, Object.notify, and Object.notifyAll.

我的疑问是,上面说的操作wait set的Elementary actions是什么操作的?还有,比如我的一个service excute了多个runnable对象,所有的线程都自动地互相添加到每个object的wait set里吗?

ringa_lee
ringa_lee

ringa_lee

全部回复(1)
大家讲道理

Elementary actions就是Object.wait, Object.notify, and Object.notifyAll,只有这三个操作能够影响到对象的wait set,当调用一个对象的wait方法,就是把当前线程添加到这个对象的wait set,notify会把wait set的线程删除一个,notifyAll会删除所有线程吧

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号