Incrementing a counter is always a good multithreaded problem. You can try something like this: Have a global counter and n threads which increment it in a thread safe way. Each of the n threads should increment the counter x number of times with x>1. Whenever the counter is incremented, the thread doing the increment should print out its name, the value before and the value after.
If you want bonus difficulty, ensure that no thread increments the counter more than once more than any other thread - in other words, every thread gets to increment before any other thread goes again.
Joined: Jan 24, 2005
Thanks I will try this out... please let me know any other interesting assignments.