Skip to content

Tag: multithreading

Designing a Guava LoadingCache with variable entry expiry

I am using Guava’s LoadingCache into my project to handle thread-{safe,friendly} cache loading and it works wonderfully well. However, there is a limitation. The current code defining the cache looks like this: I don’t specify an expiry time. The problem is that according to the values of the key, some associated values may expire and others may not. And CacheLoader

Distribute Range of Numbers between each threads

Config File I have a config file above in which I have number of threads I want to use and the client instance is able to use ID range from 1 to 1000 and suppose the client threads is set at 10, so each thread would have range of 100 id’s(basically by dividing end range with thread size) that it

Does any JVM implement blocking with spin-waiting?

In Java Concurrency in Practice, the authors write: When locking is contended, the losing thread(s) must block. The JVM can implement blocking either via spin-waiting (repeatedly trying to acquire the lock until it succeeds) or by suspending the blocked thread through the operating system. Which is more efficient depends on the relationship between context switch overhead and the time until