线程调用wait之后什么情况下会再次被唤醒呢?

 

 This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:
1. Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.

其他线程调用了notify
2. Some other thread invokes the notifyAll method for this object.

其他线程调用了notifyall
3. Some other thread interrupts thread T.

其他线程中断了次线程
4. The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.

执行的实时时间到了,如果超时时间设置为0,那么将会忽略配置的超时时间,一直等到其他线程唤醒。

The thread T is then removed from the wait set for this object and re-enabled for thread

然后线程T就从等待集合中被移除,和其他线程一起抢占资源,然后执行

scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

关注我,不迷路。


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值