public CacheBuilder < K , V > concurrencyLevel ( int concurrencyLevel ) { checkState ( this . concurrencyLevel == UNSET_INT , "concurrency level was already set to %s" , this . concurrencyLevel ) ; checkArgument ( concurrencyLevel > 0 ) ; this . concurrencyLevel = concurrencyLevel ; return this ; }
Guides the allowed concurrency among update operations . Used as a hint for internal sizing . The table is internally partitioned to try to permit the indicated number of concurrent updates without contention . Because assignment of entries to these partitions is not necessarily uniform the actual concurrency observed may vary . Ideally you should choose a value to accommodate as many threads as will ever concurrently modify the table . Using a significantly higher value than you need can waste space and time and a significantly lower value can lead to thread contention . But overestimates and underestimates within an order of magnitude do not usually have much noticeable impact . A value of one permits only one thread to modify the cache at a time but since read operations and cache loading computations can proceed concurrently this still yields higher concurrency than full synchronization .