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:
原因:当使用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 exception | Special value | Blocks | Times out | |
Insert | add(e) | offer(e) | put(e) | offer(e, time, unit) |
Remove | remove() | poll() | take() | poll(time, unit) |
Examine | element() | peek() | not applicable | not applicable |
相关文章推荐
- 一个Flume 异常(Put queue for MemoryTransaction of capacity 100 full)的排查和解决思路
- Java集合源码学习(16)_BlockingQueue接口的实现ArrayBlockingQueue
- ConcurrentLinkedQueue是非阻塞的,blockingqueue是阻塞的
- LinkedBlockingQueue和ConcurrentLinkedQueue
- ConcurrentLinkedQueue、AraayBlockingQueue、LinkedBlockingQueue 区别及使用场景
- BlockQueue中ArrayBlockingQueue和LinkedBlockingQueue
- LinkedBlockingQueue和ConcurrentLinkedQueue详细用法
- Houdini Event Queue Full. Events being dropped:的解决方案
- Spring Boot中使用Feign调用时Hystrix提示异常:"could not be queued for execution and no fallback available."以及"Rejected command because thread-pool queueSize is at rejection threshold"
- java点滴之阻塞队列:PriorityBlockingQueue,SynchronousQueue,LinkedBlockingQueue,ArrayBlockingQueue
- Queue、BlockingQueue以及利用BlockingQueue实现生产者/消费者模型
- ArrayBlockingQueue和LinkedBlockingQueue的区别
- ArrayBlockingQueue和LinkedBlockingQueue的使用
- Java多线程-BlockingQueue-ArrayBlockingQueue-LinkedBlockingQueue
- JDK源码分析—— ArrayBlockingQueue 和 LinkedBlockingQueue
- ArrayBlockingQueue和LinkedBlockingQueue的使用
- ArrayBlockingQueue与LinkedBlockingQueue的使用及区别
- ArrayBlockingQueue、LinkedBlockingQueue、ConcurrentLinkedQueue
- ArrayBlockingQueue 与LinkedBlockingQueue
- ConcurrentLinkedQueue 以及 BlockingQueue