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.
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
© 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