I realised I have a massive knowledge gap when it comes to multi-threaded applications and concurrent programming. I've covered some basics in the past, but most of it seems to be gone from my mind, and it is definitely a field that I want, and need, to be more knowledgeable about.

What are the best resources for learning about building concurrent applications? I'm a very practical oriented person, so if said book contains concrete examples the better, but I'm open to suggestions. I personally prefer to work in pseudocode or C++, and a slant toward game development would be best, but not required.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

3 Answers
3

Java Concurrency in Practice - by the author of much of Java's concurrency utils. Somewhat Java-specific, but very clear and informative about the dangers and pitfalls of threads.

The Art of Concurrency - not a scintillating theoretical treatise as the title suggests, in fact a rather folksy and down-to-earth compendium of useful advice and examples.

Programming Concurrency on the JVM - This one actually is a scintillating theoretical treatise, but very, very readable and insightful. If you need to know what STM or actors are, what their strengths and weaknesses are and why, this book will tell you.

There are many dedicated utility libraries such as the Intel Threading Building Blocks or Apple's Grand Central Station - these generally have their own dedicated manuals, which are usually quite good, and anyway are mandatory reading if you want to do something big with them.

Its slanted towards C# but the concepts are entirely applicable to other languages. He also provides the tutorial as a PDF download in english and several other languages. I would recommend it due to the combination of example code, step by step explanations of the code and excellent sequence and state diagrams accompanying the examples.

There are now threading facilities in the C++ standard. So if you want to learn in C++, I suggest reading a simple review of the new language feature before heading over to a generic threading tutorial. Then go back and review the standard in more detail later.

In practice, threading is one of those things that most people think they understand, but don't. I went to a talk from a static analysis researcher who identified race conditions in an IBM research database (Java), in a linux filesystem (C), and in some other pretty high-profile projects. Some of the projects were written by respected experts in concurrency and threading. Be aware that making thread-safe code is difficult and that the knowledge gap is not exclusive to those who recognize it in themselves.

Though it will not directly help you in game programming, I would recommend looking at some MPI tutorials (sorry, no specific recommendations). While it seems difficult to write correct concurrent code with threads, it seems rather easy to do it with message passing. Indirectly, the hope is that exploring different concurrency models will help your own thought process on structuring your code to be thread-safe.