a good application to see benefits of multi-threading

I am trying to get better at writing multi-threaded applications, things like coming up with the right algorithm so that threads don't block each other and where required have the right synchronization between threads. This will be in C/Linux.

Can anyone suggest a simple application that I can write, which can clearly demonstrate the increase in performance/throughput when run as a multi-threaded vs single-threaded in a multi-core CPU.



The Intel Threading Challenges provide interesting puzzles if what you want is to sharpen your skills. Here's one example problem:


Matrix multiplication is a fairly good starting point. It is parallelizable and also requires some synchronization for the reduction step.

You could load an image and perform some simple pixel operations in multiple threads. For example convert from RGB to HSV, or something like that...

This would be simple yet very much in step with actual practice.

Independent computations are going to give you the best gains with multiple threads. For a simple demonstration of multiple-thread performance, just do a simple computation (e.g., find the Nth fibonacci number) a few times. Is that too simple?

Need Your Help

How do you query multiple databases for one view in ASP.NET MVC?

asp.net-mvc data-binding

I have three databases, x, y, z. Let's assume MS can speak to all of them via odbc or something else.