Source:
<code>public void testRandomBehaviorParallelly() throws InterruptedException { final int RANGE = 32768; final int INIT_DATA = 50000; <START> final int THREAD = 8; <END> final int COUNT = 1000000; final RandomBehavior rb = new RandomBehavior(true); CompactedConcurrentSkipListMap<Integer, String> mapForTest = createMapForTest(true); ConcurrentSkipListMap<Integer, String> mapForStand = createMapForStand(); final MapContext[] mc = new MapContext[THREAD]; for (int i = 0; i < THREAD; ++i) { mc[i] = new MapContext(mapForTest, mapForStand, RANGE, i, THREAD); } BehaviorCollections.initRandom(RANGE); BehaviorCollections.initData( new MapContext(mapForTest, mapForStand, RANGE), INIT_DATA); System.out.println("There are " + mc[0].mainMap2.size() + " element in this map"); final Performace performance = new Performace(); List<Thread> threads = new ArrayList<>(); for (int i = 0; i < THREAD; ++i) { final MapContext context = mc[i]; Thread t = new Thread(new Runnable() { @Override public void run() { try { for (int c = 0; c < COUNT; ++c) { Behavior b = rb.nextBehavior(context.type); if (context.type != InputType.MAIN_MAP) { context.viewOps += 1; } long start = System.nanoTime(); b.doBehavior(context); long lat = System.nanoTime() - start; performance.addOps(b.getName(), lat); if (context.viewOps > 20) { context.reset(); } } } catch (Throwable e) { e.printStackTrace(); Assert.assertFalse(e.getMessage(), true); } } }); threads.add(t); } for (Thread t : threads) { t.start(); } for (Thread t : threads) { t.join(); } System.out.println("There are " + mc[0].mainMap2.size() + " element in this map"); System.out.println("Performace:"); System.out.print(performance.toString()); }</code><technical_language>thread count related number of cores for processor</technical_language>

Target:
public void testRandomBehaviorParallelly() throws InterruptedException { final int RANGE = 32768; final int INIT_DATA = 50000; final int THREAD = Runtime.getRuntime().availableProcessors(); final int COUNT = 1000000; final RandomBehavior rb = new RandomBehavior(true); CompactedConcurrentSkipListMap<Integer, String> mapForTest = createMapForTest(true); ConcurrentSkipListMap<Integer, String> mapForStand = createMapForStand(); final MapContext[] mc = new MapContext[THREAD]; for (int i = 0; i < THREAD; ++i) { mc[i] = new MapContext(mapForTest, mapForStand, RANGE, i, THREAD); } BehaviorCollections.initRandom(RANGE); BehaviorCollections.initData( new MapContext(mapForTest, mapForStand, RANGE), INIT_DATA); System.out.println("There are " + mc[0].mainMap2.size() + " element in this map"); final Performace performance = new Performace(); List<Thread> threads = new ArrayList<>(); for (int i = 0; i < THREAD; ++i) { final MapContext context = mc[i]; Thread t = new Thread(new Runnable() { @Override public void run() { try { for (int c = 0; c < COUNT; ++c) { Behavior b = rb.nextBehavior(context.type); if (context.type != InputType.MAIN_MAP) { context.viewOps += 1; } long start = System.nanoTime(); b.doBehavior(context); long lat = System.nanoTime() - start; performance.addOps(b.getName(), lat); if (context.viewOps > 20) { context.reset(); } } } catch (Throwable e) { e.printStackTrace(); Assert.assertFalse(e.getMessage(), true); } } }); threads.add(t); } for (Thread t : threads) { t.start(); } for (Thread t : threads) { t.join(); } System.out.println("There are " + mc[0].mainMap2.size() + " element in this map"); System.out.println("Performace:"); System.out.print(performance.toString()); }