You want to do those examples to understand concurrency? If yes, then I recommend reading "Java Concurrency in Practice". Although I haven't read it yet, it's a very highly regarded book when it comes to Java concurrency. The reviews are here
I reckon you must have already solved the producer consumer problem using multiple techniques.
I know that blocking queues is the way to go for it, but the other ways teach you the basics that are critical.
But I'm sure you must be past that stage.
I reckon you must have already written programs that use Locks, Conditions etc.
If yes, you might want to write programs that make use of thread pools, executors, and schedulers.
Have you used types like AtomicInteger etc already? If not, just knowing how they work might help.
You could also look at the techniques to minimize synchronization.
By the way, in the book 'Java Threads'- Edition 3, the authors have demonstrated simple concepts in the very first chapter by the means of a simple game. With every chapter
the authors add something more advanced to that same game.
This way they are able to explain to their readers the subtle differences
amongst various approaches.
That same game ... all through till chapter 14.
It's awesome. And when there is a need to explain something more, something different,
you will see a different example. There are several examples in that book and they are examples that
will teach you how to write that kind of code in real applications.
Certain exercies can be
a. program to create a deadlock . if possible link it with Out of memory error .. take dump and solve the deadlock
b. program to use cyclic barrrier, semaphores, Locks, CountdownLatch etc
OR
we can write a sample Online Bidding web application [ kind of ebay] .. where multiple threads try to bid for same product(s)
Post by:autobot
I promise I will be the best, most loyal friend ever! All for this tiny ad:
a bit of art, as a gift, the permaculture playing cards