Threading is a complicated, error-prone topic. If you're going to do a lot of work with threads, I suggest you read one or both of the following books:
by Scott Oaks and Henry Wong
This book shows you how to take advantage of Java's thread
facilities: where to use threads to increase efficiency, how to use
them effectively, and how to avoid common mistakes. It covers the
Thread
and ThreadGroup
classes, the
Runnable
interface, and the language's
synchronized
operator, as well as problems like deadlock,
race conditions, and starvation.
by Doug Lea
This is the best book available on multi-threaded programming, but it's a little tough going in parts.
by Brian Goetz, Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes, Doug Lea
Focuses on the new threading features introduced in Java 5