Sharing Data Between Threads
This lesson explains how data is shared in between threads.
We'll cover the following...
Chapter overview
The previous chapter was about threads sharing information through message passing. As mentioned in that chapter, message passing is a safe method of concurrency.
Another method involves more than one thread reading from and writing to the same data. For example, the owner thread can start the worker with the address of a bool
variable, and the worker can determine whether to terminate or not by reading the current value of that variable. Another example would be where the owner starts multiple workers with the address of the same variable so that the variable gets modified by more than one worker.
One of the reasons why data ...