java - How to use and set appropriately concurrency level for ConcurrentHashMap? -
i working around 1000 elements in concurrenthashmap . default concurrency level 16 . can me algorithm or factors can identify concurrency level suitable scenario or in way concurrency level affects processing of multiple threads .
concurrenthashmap<string, string> map=new concurrenthashmap<string, string>(500,1,20);
20 concurrency level (dummy value) .need set efficiently
according docs:
the allowed concurrency among update operations guided optional
concurrencylevel
constructor argument (default16
), which used hint internal sizing. table internally partitioned try permit indicated number of concurrent updates without contention. because placement in hash tables random, the actual concurrency vary. ideally, should choose value accommodate many threads ever concurrently modify table. using higher value need can waste space , time, , lower value can lead thread contention.
so need answer 1 question:
what number of threads ever concurrently modify table?
Comments
Post a Comment