CS 221
Advanced Programming

Friday, April 24

Threading Part 3

Today we covered Atomic Variables and immutable objects to further look at ways to protect our data in a multi-threaded environment. We then looked at the problems that arise when coordinating execution between multiple threads, namely: Deadlock, Livelock, and Starvation. We began looking at the producer-consumer scenario but didn't have a chance to look at the code yet. We did look at code that produced a deadlock between two very polite bowing gentelmen. We also looked at how a mutex can be used to improve the performance of a thread waiting on another thread to complete an action. We took that same mutex and used it to un-stick the bowing gentleman and end their deadlock.