Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share

locked by Thomas Owens Apr 17 at 11:37

closed as off-topic by jwenting, Snowman, Thomas Owens Apr 17 at 11:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Snowman, Thomas Owens
If this question can be reworded to fit the rules in the help center, please edit the question.

    
you'll find plenty here: stackoverflow.com/questions/194812/… –  alfasin Feb 18 '12 at 11:35
    
You prefer to "work in pseudocode"? I hope that works for you! :) –  logc Apr 17 at 10:49

5 Answers 5

These are the books I have found useful lately:

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.

share

I have found this free threading resource put up by Joe Albahari excellent ...

Threading in C#

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.

The tutorial is in five parts:

Its available in book form here: C# 4.0 in a Nutshell (chapters 23 and 24)

share
1  
+1, this is my usual "go-to" reference for threading/concurrency/parallelism in .NET –  MatthewKing Apr 16 '12 at 4:58

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.

share

To learn about concurrency, use a language that was designed for concurrency. Golang is a good choice since it has built-in support for concurrency and a C-like syntax which makes the language easy to learn for most programmers.

It has message passing, mutexes etc which cover almost all of your concurrency needs and which have more complicated equivalents in other languages.

For example, receiving an int from another thread into variable a using MPI in C:

MPI_Recv(&a, 1, MPI_INT, 0, 0, MPI_COMM_WORLD,MPI_STATUS_IGNORE);

Receiving an int into variable a from another (user) thread in go:

a := <-c

To learn go in practice, check out the go tour, where you can write, compile and run go code in your browser.

tour.golang.org

To skip to the concurrency part

http://tour.golang.org/concurrency/1

My former professor held a very popular short course for first year CS students on the topic of concurrency. For a quick, but thorough, introduction to what concurrency is, I definitely recommend reading the this.

Fundamentals of concurrent programming

share

There are many concurrency models so you'd better have a good idea about all before you decide which one to pick. For that, I recommend the book Seven Concurrency Models in Seven Weeks: When Threads Unravel. Check the reviews and the TOC and you can see why this is a good book. And it is also recent (2014).

share

Not the answer you're looking for? Browse other questions tagged or ask your own question.