A BlockingQueue does not accept null elements. Implementations throw NullPointerException
2 下表一些常用方法
| 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 |
3 如果限定了BlockingQueue長度時最好使用上標Special value的那一些方法
4 BlockingQueue本身的方法是线程安全的
但是addAll, containsAll, retainAll and removeAll不是线程安全的。
沒有留言:
張貼留言