views:

321

answers:

8

I'm aiming to learn about concurrency in Java. Currently my state of knowledge is poor. I'm pretty sure I know what "volatile" means. I sort of know what "synchronized" means. Sometimes. I've never written code that starts threads or manages them. Outside of this issue, I feel confident and at home working in Java.

I'm looking for suggestions for a small project or program which will require understanding concurrency to work correctly and efficiently.

Any suggestions much appreciated!

+1  A: 

This is not a Complete project but it contains some source codes as well. I think it would be great for get a good understanding about threading.

Threading in Java

Chathuranga Chandrasekara
+1  A: 

If you are an somewhat experienced programmer it might be interesting to create a little server for prescribing to share prices that uses the Fix Protocol. It would need to be able to cope with several clients (and then you get to learn Swing or some web techs) which requires concurrency.

If you are a beginner I suggest something simpler like a producer thread with a couple of consumer threads and you would get extra points if you can graphically show the process.

willcodejavaforfood
+6  A: 

If you're really just starting then probably the producer-consumer problem is a good way to start:

http://en.wikipedia.org/wiki/Producer-consumer_problem

Don't read too much because the Wikipedia article also contains a solution to the problem :-)

Benedikt Eger
+1 . IMO this is one of the best ways to learn threading concepts.
talonx
Oops...'ways' = 'examples'
talonx
Had a quick look and I can see immediately that I don't know how to do that right. So it fits the bill and I shall give it a go - many thanks!
jjujuma
+1  A: 

A common learning project for concurrency and networking is to write a chat program. It is similar to the FIX server suggestion but you just pass text around.

Peter Lawrey
+4  A: 
dfa
Hmmm... nice idea
Chathuranga Chandrasekara
There is an additional burden of solving a puzzle, which would distract from understanding the principles of concurrent programming.
+2  A: 

When I read concurrent systems programming at the university, we built a video surveillance system - one master PC that fetched video data from one or more slave PC's with webcams. I remember that project since it really made you grok both efficient network programming, real-time issues and JNI :)

Christoffer
A: 

I strongly recommend the book Java Concurrency In Practice as a resource while you are working on whichever project you choose.

Darron
A: 

Write a matrix-multiply algorithm. Parallelize it. Optimize it. See how it scales especially if you have a multi-core machine. That would be a fun project.

Julien Chastang