Yes, like that, thanks,
Paul.

> On Jun 15, 2018, at 11:01 AM, Brent Christian <brent.christ...@oracle.com> 
> wrote:
> 
> On 6/15/18 10:35 AM, Paul Sandoz wrote:
>> I would also publish the map in readHashtable after you have placed in the 
>> keys/values.
> 
> Like this?
> 
>         // create CHM of appropriate capacity
> -        map = new ConcurrentHashMap<>(elements);
> +        ConcurrentHashMap<Object,Object> tmpMap = new 
> ConcurrentHashMap<>(elements);
> 
>         // Read all the key/value objects
>         for (; elements > 0; elements--) {
>             Object key = s.readObject();
>             Object value = s.readObject();
> -            map.put(key, value);
> +            tmpMap.put(key, value);
>         }
> +
> +        UNSAFE.putObjectVolatile(this, MAP_OFFSET, tmpMap);
>     }
> 
> -B

Reply via email to