摘要:序是一款對并發(fā)數(shù)據(jù)結(jié)構(gòu)進(jìn)行增強(qiáng)的并發(fā)工具,主要提供了以及的增強(qiáng)數(shù)據(jù)結(jié)構(gòu)。只有幾個方法對比主要是操作之后沒有立即返回是對的增強(qiáng),對多的支持以及高并發(fā)更新提供更好的性能。是對的簡單包裝以支持的接口。
序
JCTools是一款對jdk并發(fā)數(shù)據(jù)結(jié)構(gòu)進(jìn)行增強(qiáng)的并發(fā)工具,主要提供了map以及queue的增強(qiáng)數(shù)據(jù)結(jié)構(gòu)。原來netty還是自己寫的MpscLinkedQueueNode,后來新版本就換成使用JCTools的并發(fā)隊(duì)列了。
增強(qiáng)mapConcurrentAutoTable(后面幾個map/set結(jié)構(gòu)的基礎(chǔ))
NonBlockingHashMap
NonBlockingHashMapLong
NonBlockingHashSet
NonBlockingIdentityHashMap
NonBlockingSetInt
增強(qiáng)隊(duì)列SPSC - Single Producer Single Consumer (Wait Free, bounded and unbounded)
MPSC - Multi Producer Single Consumer (Lock less, bounded and unbounded)
SPMC - Single Producer Multi Consumer (Lock less, bounded)
MPMC - Multi Producer Multi Consumer (Lock less, bounded)
mavenConcurrentAutoTableorg.jctools jctools-core 2.1.0
替代AtomicLong,專門為高性能的counter設(shè)計(jì)的。只有幾個方法
public void add( long x ); public void decrement(); public void increment(); public void set( long x ); public long get(); public int intValue(); public long longValue(); public long estimate_get();
對比AtomicLong主要是操作之后沒有立即返回
public final long incrementAndGet(); public final long decrementAndGet()NonBlockingHashMap
NonBlockingHashMap是對ConcurrentHashMap的增強(qiáng),對多CPU的支持以及高并發(fā)更新提供更好的性能。
NonBlockingHashMapLong是key為Long型的NonBlockingHashMap。
NonBlockingHashSet是對NonBlockingHashMap的簡單包裝以支持set的接口。
NonBlockingIdentityHashMap是從NonBlockingHashMap改造來的,使用System.identityHashCode()來計(jì)算哈希
NonBlockingSetInt是一個使用CAS的簡單的bit-vector
原來是
// --- hash ---------------------------------------------------------------- // Helper function to spread lousy hashCodes. Throws NPE for null Key, on // purpose - as the first place to conveniently toss the required NPE for a // null Key. private static final int hash(final Object key) { int h = key.hashCode(); // The real hashCode call h ^= (h>>>20) ^ (h>>>12); h ^= (h>>> 7) ^ (h>>> 4); h += h<<7; // smear low bits up high, for hashcodes that only differ by 1 return h; }
改為
// --- hash ---------------------------------------------------------------- // Helper function to spread lousy hashCodes private static final int hash(final Object key) { int h = System.identityHashCode(key); // The real hashCode call // I assume that System.identityHashCode is well implemented with a good // spreader, and a second bit-spreader is redundant. //h ^= (h>>>20) ^ (h>>>12); //h ^= (h>>> 7) ^ (h>>> 4); return h; }doc
JCTools
Java Concurrent Counters By Numbers
Lock Free Queues Index
135 Million messages a second between processes in pure Java
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://m.hztianpu.com/yun/70324.html
摘要:服務(wù)本身是一個,開起的線程數(shù)為,再加上一些其他線程,總的線程數(shù)不會超過服務(wù)內(nèi)自己沒有顯示創(chuàng)建線程或者使用線程池。問題解決找到所在后,結(jié)局方案很簡單,只需將的通過單例的方式注入到服務(wù)中,即可解決堆外內(nèi)存泄漏的問題。 內(nèi)存泄漏Bug現(xiàn)場 一個做BI數(shù)據(jù)展示的服務(wù)在一個晚上重啟了5次,由于是通過k8s容器編排,服務(wù)掛了以后會自動重啟,所以服務(wù)還能繼續(xù)提供服務(wù)。 第一時(shí)間先上日志系統(tǒng)查看錯誤日...
摘要:最近有國外網(wǎng)站對多個互聯(lián)網(wǎng)安全博客做了相關(guān)排名,小編整理其中排名前的安全博客,希望能給大家?guī)硪恍椭N恼赂骂l率篇周地址簡介谷歌在互聯(lián)網(wǎng)安全的新聞和見解。其安全部分致力于分析最新的惡意軟件威脅和漏洞。 如果你是網(wǎng)絡(luò)安全從業(yè)人員,其中重要的工作便是了解安全行業(yè)的最新資訊以及技術(shù)趨勢,那么瀏覽各大安全博客網(wǎng)站或許是信息來源最好的方法之一。最近有國外網(wǎng)站對50多個互聯(lián)網(wǎng)安全博客做了相關(guān)排...
閱讀 1758·2021-11-18 10:02
閱讀 2274·2021-11-15 11:38
閱讀 2732·2019-08-30 15:52
閱讀 2269·2019-08-29 14:04
閱讀 3291·2019-08-29 12:29
閱讀 2138·2019-08-26 11:44
閱讀 1061·2019-08-26 10:28
閱讀 905·2019-08-23 18:37