您的位置:首页 > 产品设计 > UI/UE

BlockingQueue的异常Queue full

2013-04-10 17:13 218 查看
生产异常日志:java.lang.IllegalStateException: Queue full

原因:当使用add方法的时候,队列满了,再放入元素,就会报这个异常

解决方法:将add方法替换成put方法,队列变成阻塞队列。

引用java doc:

BlockingQueue methods come in four forms, with different ways of handling operations that cannot be satisfied immediately, but may be satisfied at some point in the future: one throws an exception, the second returns a special value (either null or false, depending on the operation), the third blocks the current thread indefinitely until the operation can succeed, and the fourth blocks for only a given maximum time limit before giving up. These methods are summarized in the following table:

Throws exceptionSpecial valueBlocksTimes out
Insert
add(e)
offer(e)
put(e)
offer(e, time, unit)
Remove
remove()
poll()
take()
poll(time, unit)
Examine
element()
peek()
not applicablenot applicable

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: