What is the closest to ConcurrentHashMap and NavigableMap in Java?
ilya-stromberg
ilya-stromberg-2009 at yandex.ru
Fri Nov 15 08:20:03 PST 2013
On Friday, 15 November 2013 at 15:21:59 UTC, Jacek Furmankiewicz
wrote:
> So what happens when the "write" operation is doing
>
> map[1] = map[1].editData(5);
>
> and at the same time 50 threads are simultaneously reading the
> value in map[1]?.
>
> Is that reassignment operation thread safe?
> Or would I get corrupted reads with potentially a partially
> overriden value?
>
> Jacek
Yes, this is thread safe.
Put attention to the `MyMap` class definition, it's marked as
`synchronized`. It means that all class functions use the same
Mutex. So, "write" operation will block map and all 50 threads
will wait.
More information about the Digitalmars-d-learn
mailing list