This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Threads based proj. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Threads based proj." Watch "Threads based proj." New topic

Threads based proj.

Waez Ali
Ranch Hand

Joined: Jan 24, 2005
Posts: 43

I have studied threads but I want to develop one small project to really get clear picture of apis and how it works.

If you know any sources/links/ or you would propose any small proj that I can develop in multithreads.. it would be really helpful.

Thank You
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 187
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.
Waez Ali
Ranch Hand

Joined: Jan 24, 2005
Posts: 43
Thanks I will try this out... please let me know any other interesting assignments.
I agree. Here's the link:
subject: Threads based proj.
It's not a secret anymore!