Re: My (lack of )wisdom about threads
Stefan Ram wrote:
Does anyone else like this advice?
Sometimes, but it's usefulness is limited. It's like saying "As much as
possible, try to use local variables because they have the most limited
scope." By itself, that statement won't allow you to design correct
programs. There's much more to programming than just variable scope.
So, when I should ever start to use threads in Java beyond
what I am forced to do, I'd implement a message-passing
framework/library/pattern for my threads first.
The solution here is simple: you must buy and read Java Concurrency in
Practice.
<http://jcip.net/>
There's just no way you can be a Java programmer today and not know how
to deal with threads. Threads are not hard, but I didn't understand
them either until I read the first chapter of that book. Then it all
cleared up.
This is not rocket science. Threads seem mysterious and hard until you
have the full explanation, then it all makes sense. If you can
understand basic algorithms -- for example, if you can write a basic
tree traversal -- then you have the smarts to understand threads. Don't
procrastinate any longer. Buy the book, read the first chapter, get
started now.