Wrap-Up

Threads-and-locks programming probably divides opinion more than any of the other techniques we’ll cover. It has a reputation for being fiendishly difficult to get right, and plenty of programmers shrink from it, avoiding multithreaded programming at all costs. Others don’t understand the fuss—a few simple rules need to be followed, and if you follow them it’s no harder than any other form of programming.

Let’s look at its strengths and weaknesses.

Strengths

The primary strength of threads and locks is the model’s broad applicability. As you might expect, given that they’re the basis upon which many of the approaches we’ll cover later are built, they can be applied to a very wide range of problems. Because they are ...

Get Seven Concurrency Models in Seven Weeks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.