Summary
In this chapter, we discussed some of the possibilities available to you when using threads, and we pointed out some trouble spots to avoid. We discussed safe threading issues, threads and Swing, blocking, waiting, and a host of other topics.
The best way to understand threading is to design your threading scheme, make predictions about how it will function, and then test those predictions with the handy method in the Thread class, holdsLock(Object). Thread’s getState() and getStackTrace() methods can be very handy for checking what another thread is doing. If your threads aren’t behaving the way you expected them to, explicitly record your assumptions (we suggest writing them down) and then examine them one by one. Threading is a lot like grammar: There are a lot of rules, but eventually you develop a sense for what works and what doesn’t. (Or so I’m told.)
As you read the next chapters, please don’t hesitate to refer back to this chapter when needed.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2006 Andrew Monkhouse and Terry Camerlengo
About this chapter
Cite this chapter
(2006). Threading. In: SCJD Exam with J2SE 5. Apress. https://doi.org/10.1007/978-1-4302-0107-6_4
Download citation
DOI: https://doi.org/10.1007/978-1-4302-0107-6_4
Publisher Name: Apress
Print ISBN: 978-1-59059-516-9
Online ISBN: 978-1-4302-0107-6
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)