美文网首页
高效的Map,Set,Queue

高效的Map,Set,Queue

作者: 辣么大大大大 | 来源:发表于2019-10-26 17:19 被阅读0次

Efficient Maps, Set, Queues

Concurrent hash map organizes buckets as trees, guaranteeing O(lgn) performance.

Automic update for map entries

Use atomic Long, Integer, Boolean

Map has merge, compute, computeIfAbsent, computeIfPresent

Bulkoperation on Concurrent Hashmaps

search, reduce, forEach

Eg:

searchValues(long threshold ...)

Threshold defines parallelism number, if map contains more elements than threshold, then bulk operation in different thread.

CopyOnWriteArrays

We can use it if there are threads iterate over the collection greatly outnumber the threads that mutate it.

Older Thread-Safe Collections

Do not use

List<E> list = Collections.synchronzedList<new ArrayList<E>());

Map<K,V> map = Collections.synchronzedMap<new HashMap<K,V>());

Parallel Sort

Arrays.parallelSort use forkjoin mechnism.

相关文章

网友评论

      本文标题:高效的Map,Set,Queue

      本文链接:https://www.haomeiwen.com/subject/eckuvctx.html