Java container selected high concurrency

1. For Map / Set of use

(1) non-concurrent

  • HashMap
  • TreeMap
  • LinkHashedMap

(2) non-complex, low-concurrency concurrency

  • HashTable
  • Collections.sychronizedXXX

(3) complex, high concurrency concurrency

  • ConcurrentHashMap // do not need to sort
  • ConcurrentSkipListMap // need to sort

2. Use the queue

(1) non-concurrent

  • ArrayList
  • LinkedList

(2) non-complex, low-concurrency concurrency

  • Collections.sychronizedXXX
  • Vector

(3) complex, high concurrency concurrency

  • ConcurrentLinkedQueue
  • CopyOnWriteList
    • Copy, written in this new time of writing, if at the same time happened to read, share, write very little reading before attending a very long time
  • BlockingQueue
    • LinkedBlockingQueue (unbounded queue
    • ArrayBlockingQueue (bounded queue
    • TransferQueue (blocking execution
    • SynchronousQueue (special TransferQueue, capacity 0, put is approximately equal to the transfer TransferQueue
  • DelayQueue
    • Queue elements to achieve Delayed interface Delayed interface inherits the Comparable interface, you need to set your own time waiting in the queue, before removing after arrival time
Published 52 original articles · won praise 9 · views 6191

Guess you like

Origin blog.csdn.net/weixin_43553694/article/details/104496266