Skip to main content
  • 201 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 49.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints 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

Publish with us

Policies and ethics