dcsimg
Is synchronized WeakHashMap really thread-safe ?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jeff_Bobier
Posted On:   Tuesday, April 23, 2002 02:06 AM

Hi everybody,


I know this question looks like tautology but I intend to use a WeakHashMap in a multithread environment.


By reading the wonderful jGuru FAQ, I understand that I must use

Collection.synchronizedMap(myWeakHashMap)
to get a thread safe Map, and that I could equally wrap the getters/setters that use the Map with
synchronized(myWeakHashMap) { ... }
.


So far, so good. But what happens when a weak key is collected by the GC ? Is the inner structure of the WeakHashMap modified ? In that case, is the modification thread-safe ?


Thank you in advance !


Jeff

About | Sitemap | Contact