java我爱编程

java 并发集合

2018-05-27  本文已影响0人  spraysss

阻塞集合和非阻塞集合

阻塞集合有BlockingQueue和BlockingDeque

a 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

队头元素 (Head)

Throws exception Special value Blocks Times out
Insert addFirst(e) offerFirst(e) putFirst(e) offerFirst(e, time, unit)
Remove removeFirst() pollFirst() takeFirst() pollFirst(time, unit)
Examine getFirst() peekFirst() not applicable not applicable

队尾元素(Tail)

Throws exception Special value Blocks Times out
Insert addLast(e) offerLast(e) putLast(e) offerLast(e, time, unit)
Remove removeLast() pollLast() takeLast() pollLast(time, unit)
Examine getLast() peekLast() not applicable not applicable

非阻塞线程安全双端队列

ConcurrentLinkedDeque

上一篇下一篇

猜你喜欢

热点阅读