亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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 關注
  • 651 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號