Journal Week 5
The most interesting piece was about the magic of concurrency. Rather than just having one path of execution, threading allows for multiple paths of execution to happen at once. But then a problem can happen when multiple threads reach a part of the code where resources or variables are shared amongst different processes. It’s okay if they are just reading the data, but if information is going to be read and overwritten it becomes a problem. If two threads, try to access and manipulate data at the same time then it may cause problems as the variable or resources are no longer the indented values. This dilemma where resources are being read and overwritten at the same time is called a race condition. With race conditions causing unpredictable results, mutexes come to the rescue to help control the rate at which threads access critical sections Mutex is short for mutual exclusion. Mutexes serve as a “lock” around critical parts of code. This l...