[concurrency-interest] Questions on ConcurrentHashMap

Grace Kwok gykwok at gmail.com
Thu Nov 29 00:52:55 EST 2007

Thanks all.

Hi David,

> This won't cause task.run() to execute. Though you could create a custom
> FutureTask that provides that functionality - ie first getter runs, and uses
> internal synchronization.

1) Thanks all for catching the fact that it won't execute.  Could you
explain further this part - " first getter runs, and uses internal
synchronization" ?  What do you mean by "internal" synchronization?

> This doesn't invalidate the map for callers of getValue() that have already
> retrieved the old map from getMyCache() but have not yet executed get(key)
> on it.

I am fine with that.  I just need my map to be in a consistent
state;i.e. all entries of the map are from previous loading or all
entries of the map are from new loading.  For instance, if I iterate
thru the map,  I don't want a map containing half entries of new
values and half entries with old values.  In between loadings, there
would be many concurrent gets on the map.

One more question,

FutureTask task = new FutureTask();

If task.get() is called before task.run(), what would happen?
Does task.get() waits till task.run() is run and finished?

Thanks, Grace

More information about the Concurrency-interest mailing list