Patterns in programming means a concrete and standard solution to a given problem. Usually, programming patterns are the result of people gathering experience, analyzing the common problems, and providing solutions to these problems.
Since parallel programming has existed for quite a long time, there are many different patterns that are used to program parallel applications. There are even special programming languages to make programming of specific parallel algorithms easier. However, this is where things start to become increasingly complicated. In this chapter, I will provide you with a starting point from where you will be able to study parallel programming further. We will review very basic, yet very useful, patterns that are quite helpful for many common situations in parallel programming.
First, we will be using a shared-state object from multiple threads. I would like to emphasize that you should avoid it as much as possible. As we discussed in previous chapters, a shared...