December 2022
Intermediate to advanced
528 pages
15h 41m
English
The most common way threads interact is by sharing objects. Objects that can be freely shared without the need for threads to coordinate accesses are said to be thread-safe. Immutable objects are naturally thread-safe, but mutable objects need to rely on internal strategies to ensure thread-safety, often by locking. Different locking designs allow thread-safe objects to expose more or less of their synchronization strategy, resulting in a trade-off between flexibility and risk of misuse.
Earlier examples have shown that programs can easily behave incorrectly when data is shared by multiple threads. What all these examples have in common is that the data being shared is mutable: an integer ...
Read now
Unlock full access