为了账号安全,请及时绑定邮箱和手机立即绑定

Balking 和 wait(), 什么时候用

Balking 和 wait(), 什么时候用

HUWWW 2018-08-01 06:14:13
The BlockingQueue interface in Java includes an operation, offer(),that uses balking to add an element to the end of the queue if possible, andanother operation, put(), that uses guarded suspension to add an element tothe end of the queue. Under which circumstances would you use one of theseoperations instead of the other, and why?题目大概是问什么时候用 offer() 什么时候用 put(), 因为他们的implemention其实不一样,offer 是用 balking,就是如果出错就忽视, 或者throw exception。 put 就是如果满了就call wait()。 所以我的问题是什么时候用这两个方法?
查看完整描述

1 回答

?
湖上湖

TA贡献2003条经验 获得超2个赞

有响应速度要求,或担心服务器卡死的用offer,其他情况用put。


查看完整回答
反对 回复 2018-08-09
  • 1 回答
  • 0 关注
  • 659 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号