Question

With the rise of multicore CPUs on the desktop, multithreading skills will become a valuable asset for programmers. Can you recommend some good resources (books, tutorials, websites, etc.) for a programmer who is looking to learn about threaded programming?

Was it helpful?

Solution

Take a look at Herb Sutter's "The Free Lunch Is Over" and then his series of articles on Effective Concurrency.

OTHER TIPS

Joseph Albahari wrote a good overview of Threading in C# here:

http://www.albahari.com/threading/

I've honestly never read it myself, but Concurrent Programming in Java is a book I've heard recommended by several people.

I write about multithreading and concurrency in C++ on my blog. I'm also writing a book on concurrency in C++: C++ Concurrency in Action.

I've read (most of) Java Concurrency in Practice by Brian Goetz, which is very good.

There is obviously a Java-based theme running through the book (using Java specific implementations of threads, locks etc.), but pretty much all of the principles can be applied to other languages.

The author's home page contains a list of articles he has written, some of which include threading related stuff. Maybe start there and if you like his style, buy the book.

For a great guide and reference for concurrency programming in C# (or .NET in general) I'd recommend the MSDN What Every Dev Must Know About Multithreaded Apps article by Vance Morrison on MSDN. It contains a great deal of best-practice information and caveats about multithread development

I maintain a linkblog for concurrency articles, blogs, and projects at:

http://concurrency.tumblr.com

I usually post a link or two per day on a variety of topics (threads, actors, locking, parallel programming) in a variety of environments (Erlang, Java, Scala, .NET, C++, Ruby, Python, etc).

It's Delphi specific, but no reason why the concept wouldn't apply to any other language!

Multi Threading Tutorial

http://www.cilk.com/multicore-e-book/

That's a nice general overview of the sitution, if you're looking for tuorials and books it might be best to specify a language as a starting point so you can mess around with some code.

The Erlang programming language provides an easy-to-use style of concurrent programming. You may never actually use Erlang, but the concepts are transportable to other languages. You might want to read the book Programming Erlang: Software for a Concurrent World .

Fans of functional programming claim that there is no need to learn anything new. Just use a pure functional language, and the compiler or interpreter will automatically parallelize everything. So you might want to learn Haskell, OCaml, or another functional language.

I don't know what exactly you are looking for, but if you are doing WindowsForms development the following blog post is worth every minute reading: WinForms UI Thread Invokes: An In-Depth Review of Invoke/BeginInvoke/InvokeRequred

I think Boost.Threads is a great C++ concurrency library to learn, especially if you just want to get started in writing multithreaded applications. The code is very succinct and easy to understand, plus the next C++ standard will likely include a threading library based on Boost.Threads (tutorial: http://www.ddj.com/cpp/184401518)

If you want to have a go at doing a highly parallel version of a simple task, or see real solutions, you could do worse than look at the wide finder project. Basically it's about how to do parallel regex matching of log files efficiently, but trying to add as little code as possible.

Participants have submitted solutions in many different languages and the performance results are posted. The original project has now finished and there is now wide finder 2 taking the work on.

CodingHorror has a good introduction to wide finder.

For a rich, thorough treatment of the subject, with a good balance between computer science and practice, I recommend The Art of Multiprocessor Programming. A lot of examples are in object-oriented code, i.e. Java, with other languages scattered throughout. It just depends on the topic being covered. What I really love about this book is that it discusses how common algorithms should be implemented in a concurrent design. Of course, there's so much more!

For general concepts and a treatment of pthreads, I really like Programming with POSIX Threads. Being the library and API that it is, it's in C.

For Windows and C# developers, check out Joe Duffy's blog. Joe works on parallel libraries, infrastructure, and programming models in Microsoft's Developer Division. He has a book coming in Nov. 2008 titled Concurrent Programming on Windows (Amazon link).

Also, don't miss the Godfather's blog: Herb Sutter's Sutter's Mill. He has links to all his articles in Dr. Dobb's Journal and more. Click his Concurrency category.

CPU manufacturers websites have some interesting content:

http://developer.amd.com/documentation/articles/Pages/default.aspx#parallel

http://software.intel.com/en-us/multi-core

Also Intel's opensource threading library has some good references:

http://www.threadingbuildingblocks.org/

If you work with C#, the book "C# 2008 and 2005 threaded programming", by Gaston C. Hillar - Packt Publishing - http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book , will help you. Highly recommended for C# programmers, because you can download the code with funny examples that exploit your multicore computer. The book is a nice guide with a lot of code to practice. It tells stories while it explains the most difficult concepts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top