C# – Looking for a good exercise to help me get better at Multithreading

cmultithreadingnet

I think of myself as a pretty decent developer, however when it comes to multithreading I'm a total n00b. I mean the only multithreading I've done at work was the very basic stuff like spawning off multiple threads using the ThreadPool to do some background work. No synchronization was necessary, and there was never any need to create threads manually.

So, my question is this; I want to write some application that will need to be heavily multithreaded and that will need to do all of the advanced things like synchronization etc.. I just can't think of anything to write. I've thought of maybe trying to write my own ThreadPool, but I think I need to learn to walk before I can run. So what ideas can anyone suggest? It doesn't have to have any real world useage, it can be totally pointless and worthless, but I just want to get better. I've read tons of articles and tutorials on all the theory, but the only way to REALLY get better is by doing. So, any ideas?

Best Answer

  1. Recursive Quick Sort. Compare sort time as a function of number of threads.
  2. Craps simulator. How many rolls of the dice can you do per minute?
  3. Web page crawler. Give it a URL and download all of the child pages and images. Watch for pages that reference each other so you don't go into an infinite loop. Note that the threads will block waiting for the network response, giving you a different CPU utilization than pure calculation-based threads. Use a queue to keep track of unread pages and a dictionary to keep track of active threads. Threads that timeout go back to the queue.
  4. WCF web server. Spawn a new thread for each request. Write a multi-threaded WPF client that updates the user-interface in real-time.

Is that enough?

Related Topic