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
提交
取消