3 ms·
Mutating a hash map in Java while another thread reads it won't cause bad things like: (a) memory you don't have access to to be read; (b) other threads to cr
by ootachi 15y ago
Mutating a hash map in Java while another thread reads it won't cause bad things like:
(a) memory you don't have access to to be read;
(b) other threads to crash;
(c) the VM state to be corrupted;
(d) the GC to crash;
and so on. The Java world is still in a consistent state. In a security-oriented world, this is important.
To the reply: It's a bit pedantic for me to say this, I know, but that's still "a consistent state". Basically, a Java program can't do anything it wouldn't otherwise be able to do by modifying a hashmap concurrently. Java programs can go into infinite loops. They can't access uninitialized memory.
- 0x0 15y agoNot entirely true. It's possible to have threads enter infinite loops if you don't synchronize properly: http://stackoverflow.com/questions/1003026/hashmap-concurrency-issue http://stackoverflow.com/questions/1003026/hashmap-concurren...