“Whenever more than one thread accesses a given state variable, and one of them might write to it, they all must coordinate their access to it using synchronization.”

Brian Goetz

Brian Goetz - “Whenever more than one thread accesses a...” 1

Similar quotes

“Compound actions on shared state, such as incrementing a hit counter (read-modify-write) or lazy initialization (check-then-act), must be made atomic to avoid race conditions. Holding a lock for the entire duration of a compound action can make that compound action atomic. However, just wrapping the compound action with a synchronized block is not sufficient; if synchronization is used to coordinate access to a variable, it is needed everywhere that variable is accessed. Further, when using locks to coordinate access to a variable, the same lock must be used wherever that variable is accessed.”

Brian Goetz
Read more

“Accessing shared, mutable data requires using synchronization; one way to avoid this requirement is to not share. If data is only accessed from a single thread, no synchronization is needed. This technique, thread confinement, is one of the simplest ways to achieve thread safety. When an object is confined to a thread, such usage is automatically thread-safe even if the confined object itself is not.”

Brian Goetz
Read more

“No one can draw more out of things, books included, than he already knows. A man has no ears for that to which experience has given him no access.”

Friedrich Nietzsche
Read more

“It is a wholly deplorable state of affairs when specialists in any discipline talk only to each other, and accordingly I have sought to write a book which will communicate some of the fruits of research in a manner which will make them accessible to all.”

Richard Fletcher
Read more

“That doesn't upset too many people, but the fact that accessibility restrictions don't enter into the picture has caused more than one otherwise pacifistic soul to contemplate distinctly unpacifistic actions.”

Scott Meyers
Read more