how to lock a ConcurrentHashMap entry

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to lock a ConcurrentHashMap entry

Michele Mazzucco-2
Hi all,
is it possible to lock a single value (or a single entry <K, V>) of a
ConcurrentHashMap object?
If yes, how can I lock it?
_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
Reply | Threaded
Open this post in threaded view
|

Re: how to lock a ConcurrentHashMap entry

Doug Lea
Michele Mazzucco wrote:
> Hi all,
> is it possible to lock a single value (or a single entry <K, V>) of a
> ConcurrentHashMap object?

No. Among other reasons, there is not necessarily a single
lock associated with each entry, and get() operations normally
run without accessing any lock at all.

These are among the tradeoffs of ConcurrentHashMap vs Hashtable.
ConcurrentHashMap gives much more scalable performance at the
price of not providing any way for users to perform external
synchronization.

-Doug



_______________________________________________
Concurrency-interest mailing list
[hidden email]
http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest