How to synchronize action of multiple threads in EhCache?

1.8k Views Asked by At

How to synchronize the action of multiple threads and make sure that only one thread can access the resource at a given point in time in EhCache.

2

There are 2 best solutions below

3
Henri On

I'm not sure I understand your question but let's guess. EhCache (3, I don't know about 2) is fully thread-safe.

However, if you really mean that one entry can be used by only one thread at the time, that's not something EhCache will do as this is a specific need. You need to put your own synchronisation on top of it. Using a lock or a semaphore. For example, you could lock on the retrieved value.

0
Louis Jacomet On

I believe this question is close to another one of yours and cache-through could help you.

See https://stackoverflow.com/a/45801562/18591