高效的Map,Set,Queue

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.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容