Java集合源码学习(14)_BlockingQueue接口

时间:2021-03-25 17:54:17

继承了Queue接口;

阻塞队列,当队列为空是取数据阻塞,队列满是,插入数据阻塞;

是否是有界队列需要看具体的实现;

不允许null值;

BlockingQueue多数操作是线程安全的,批量操作除外(比如addAll, containsAll, retainAll and removeAll)

  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