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've been reading about concurrency, multi-threading, and how "the free lunch is over". But I've not yet had the possibility to use MT in my job.

I'm thus looking for suggestions about what I could do to get some practice of CPU heavy MT through exercises or participation in some open-source projects.

Thanks.

Edit: I'm more interested in open-source projects that use MT for CPU-bound tasks, or simply algorithms that are interesting to implement using MT, rather than books or papers that only describe the tools like threads, mutexes and locks, or how MT can be used to have responsive GUIs...

share|improve this question
1  
Possibly of interest: programmers.stackexchange.com/questions/24936/… –  Orbling Dec 31 '10 at 13:21
4  
Q: How would you practice concurrency and multi-threading? A: by juggling –  Steven A. Lowe Dec 31 '10 at 14:13
    
@Steven: Not that far off, really. –  Robert Harvey Jan 3 '11 at 16:36
    
The "free lunch is over" link is dead –  User Oct 13 '11 at 3:37
    
Should be ok now... –  Xavier Nodet Oct 19 '11 at 14:50

6 Answers 6

Joseph Albahari's article on Threading in C# is one of the best resources I've seen.

The Table of Contents is below. Note that some of the topics, like the Task Parallel Library, are specific to .NET, but much of it is applicable to other languages, especially Java.

GETTING STARTED
Introduction and Concepts
Join and Sleep
How Threading Works
Threads vs Processes
Threading’s Uses and Misuses
Creating and Starting Threads
Passing Data to a Thread
Naming Threads
Foreground vs Background
Thread Priority
Exception Handling
Thread Pooling
Thread Pooling via TPL
Thread Pooling Without TPL
Optimizing the Thread Pool
BASIC SYNCHRONIZATION
+ Synchronization Essentials
+ Locking
+ Thread Safety
+ Event Wait Handles
+ Synchronization Contexts
USING THREADS
+ Event-Based Asynch Pattern
+ BackgroundWorker
+ Interrupt and Abort
+ Safe Cancellation
+ Lazy Initialization
+ Thread-Local Storage
+ Timers
ADVANCED THREADING
+ Nonblocking Synchronization
+ Signaling with Wait and Pulse
+ The Barrier Class
+ Reader/Writer Locks
+ Suspend and Resume
+ Aborting Threads
PARALLEL PROGRAMMING
+ Parallel Programming
+ Why PFX?
+ PLINQ
+ The Parallel Class
+ Task Parallelism
+ Working with AggregateException
+ Concurrent Collections
+ SpinLock and SpinWait

You can also have a look at Jon Skeet's tutorial here: http://www.yoda.arachsys.com/csharp/threads/

share|improve this answer
2  
I add the Jon Skeet's c# mutlithreading page to your answer: yoda.arachsys.com/csharp/threads –  user2567 Dec 31 '10 at 0:31
1  
Second that, liked Albahari's 5 chapters extremely helpful. To practice, here's a simple exercise - Create a multiplayer tic-tac-toe game using WCF (if you know), and a simple UI - try updating the UI controls with responses from each player. Have you checked firefox code? –  Narayana Jan 3 '11 at 19:06
    
would you mind explaining more on what it does and why do you recommend it as answering the question asked? "Link-only answers" are not quite welcome at Stack Exchange –  gnat May 12 '13 at 21:50
1  
@gnat: I pasted the table of contents into my answer. –  Robert Harvey May 13 '13 at 0:20

Java Concurrency in Practice is one of the best books about multi-threading and concurrency. Although all the examples in the book are Java based, this book gives a solid explanation of MT world. It helped me a lot when I was developing a M-T system.

share|improve this answer
3  
+1 good book. And it's Java Concurrency in Practice, not Action. –  talonx Dec 31 '10 at 4:30
    
Right, thanks.. –  Sorantis Dec 31 '10 at 10:18
up vote 6 down vote accepted

Chapter 11 of the book Intel Threading Building Blocks by James Reinders is devoted to examples of algorithms and projects that make use of Parallel Computing (or Parallel Programming): a substring finder, the Game of Life, a Sieve of Eratosthenes, Matrix Multiply, and then other more advanced topics like network packet filtering and games.

share|improve this answer

I found Concurrent Programming on Windows by Joe Duffy to be very helpful. There's a lot of depth. It doesn't pull any punches, so you really get a good feel for how many ways there are to shoot yourself in the foot. It helped me to be cautious, which is the best advice I can give anyone starting with MT apps.

share|improve this answer

There's a difference between concurrency and parallelism. Concurrency is the act of doing more than one thing at a time, like writing to 2 files. Parallelism is the act of speeding up programs by using multiple cores.

Although there's no free lunch when it comes to concurrency, in parallelism the lunch is certainly becoming more free, see developments like http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell

share|improve this answer

This site has some good project examples in general. www.planet-source-code.com

Just pick a language and search for multi-threading. you should see a number of projects with source code available.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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