Each time I see an exemple of Deadlock in a book, I think :"How god, what the hell went inside his brain to design such a solution". Even with all warnings about deadlock on SCJD. in my SCJD, I don't see how you could create decently a deadlock, except maybe using notify() instead notifyAll().
It will depends of what strategy you will use in your project. Maybe some distraction could leave you into one deadlock situation, all books they approach only a deadlock situation, with a poor context, because what matter is the deadlock and not the entire application. What I mean is that the book examples didn't cover all situations , they just lead you into the best practices. On my project I discover a dead lock issue, weeks before upload my project ( thanks do Perillo test suit ), and I was impatient to upload and finish it. I try to investigate and notice that I was using mutex locks to some I/O methods, to write and upload the records. Then I simply synchronized the methods and it works fine...... When it was teste with 20, 30 clients it works fine.... But in the test suit, with lots of threads, It locks =/.
The advice is, do not underestimate the locks and test every piece of code.
The Death of one is a tragedy, but the Death of a million is just a statistic. Joseph Stalin
I think trying to avoid the deadlock in this assignment is one of the big tasks. My initial code was also not deadlock-proof when I ran Roberto Perillo's test case. It's very easy to end up with code that possibly could deadlock (from my own experience). So I would be not too confident about it. If you are able to run Roberto's test with different counters (1, 10, 100, ..., 10000) and they all complete, I'm sure you are safe
I'm glad to know that the code I created to test this part of the assigment is being helpful to everybody!
Now, Nicolas, I see this as a big opportunity to learn more about concurrency, because there are a lot of forms to implement it (take a look at the java.util.concurrent package and its subpackages), including the classical synchronization. Indeed, this is the hardest part of the assignment, so be careful with that.
I still didn't have the opportunity to read it, but I just found the Java Concurrency in Practice book, and as far as I could see, it is really really good. It can be a good resource for reseach!