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()。 所以我的問題是什么時候用這兩個方法?
添加回答
舉報
0/150
提交
取消