Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 604 Bytes

README.md

File metadata and controls

12 lines (9 loc) · 604 Bytes

Java Thread Affinity

This is self-contained library (one file, which only depends on JNA) allows to create pool of threads which have affinity with differents cores.

Currently it only works on HotSpot and Linux (but MacOS should be supported by this night ;) )

long mask = ThreadAffinity.getProcessAffinityMask();
ExecutorService threadGroupSingle = Executors.newFixedThreadPool(Long.bitCount(mask), new ThreadAffinity.SingleCPUThreadFactory(mask));
// or
ExecutorService threadGroupRandom = Executors.newFixedThreadPool(Long.bitCount(mask), new ThreadAffinity.AffinityThreadFactory(mask));