Skip to main content

Timers, Alarms, and Swing Thread Safety

  • Chapter
Taming Java Threads
  • 238 Accesses

Abstract

Tins chapter discusses the first of several classes that are useful in multithreaded programming, but which aren’t semaphores. In particular, I’ll talk about timers—objects that help execute some operation at a fixed interval or at some point in the future. I’ll discuss both the timer that is part of the Swing package (called Timer) and also a roll-your-own variety of my own (called Alarm) that is useful when the Swing Timer isn’t available or appropriate. My Alarm implementation is the most complicated of the classes in the book, and it demonstrates several important Java-programming techniques, such as how to write code that needs to suspend and resume threads without using the (now deprecated) suspend() and resume() methods. Along the way, I’ll talk about how to kill a thread gracefully without using the (also deprecated) stop() method.

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

Access this chapter

eBook
USD 24.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 34.95
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.

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2000 Allen I. Holub

About this chapter

Cite this chapter

Holub, A. (2000). Timers, Alarms, and Swing Thread Safety. In: Taming Java Threads. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-1129-7_5

Download citation

  • DOI: https://doi.org/10.1007/978-1-4302-1129-7_5

  • Publisher Name: Apress, Berkeley, CA

  • Print ISBN: 978-1-893115-10-1

  • Online ISBN: 978-1-4302-1129-7

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics