37

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

Xavier Nodet
  • 3,754

6 Answers6

16

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/

Robert Harvey
  • 200,592
14

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.

Sorantis
  • 2,720
11

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.

Xavier Nodet
  • 3,754
4

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.

2

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

1

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.

Pemdas
  • 5,395
  • 3
  • 23
  • 41