Grokking Java Interview Questions
Vote

0% completed

​

Thread Safety and Immutability

Data needs protection between threads only when two facts are true together: several threads can reach it, and at least one thread changes it. Remove either fact and no lock is necessary. An immutable object removes the second one, because it does not change after its construction. A local variable removes the first one, because no other thread can reach it.

This idea runs through all four questions: what the word thread-safe promises, which ways lead to it, why two safe calls can form an unsafe sequence, and how an object reaches other threads correctly.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content