views:

1395

answers:

18

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?

+4  A: 

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

Daniel F. Hanson
+1  A: 

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.

Tarks
+10  A: 

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

graham.reeds
+1  A: 

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.

Kristopher Johnson
+8  A: 

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

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

dmo
This is a great tutorial on the subject.
spoulson
This sure helped me.
ThatBloke
+1  A: 

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.

Lehane
+2  A: 

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

Markus Olsson
+1  A: 

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

ollifant
+1  A: 

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)

da_code_monkey
+1  A: 

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.

Hamish Downer
+5  A: 

http://www.yoda.arachsys.com/csharp/threads/

IceHeat
+1  A: 

@Kristopher Johnson

Unfortunately ocaml doesn't have a concurrent GC, so this can't be done right now. They are working on it and Jane St Ocaml Summer Project should take a step, but it likely wont be integrated in a distribution --I wouldn't do it if I were the maintainers. I will mention that you can of course use MPI, but that is process level parallelism, obviously.

nlucaroni
+1  A: 

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.

eLuke
+2  A: 

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).

Alex Miller
+1  A: 

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/

+2  A: 

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

Multi Threading Tutorial

Steve
+3  A: 

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.

Anthony Williams
A: 

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.

I have grave reservations about that book's recommendations. See my full review for details: http://msmvps.com/blogs/jon_skeet/archive/2009/03/16/book-review-c-2008-and-2005-threaded-programming-beginner-s-guide-by-gast-243-n-hillar.aspx
Jon Skeet