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.

Reply via email to