CHAPTER 4

image

Additional Thread Capabilities

Chapters 1 through 3 introduced you to the java.lang.Thread class and java.lang.Runnable interface, to synchronization, and to waiting and notification. In this chapter, I complete my coverage of thread basics by introducing you to thread groups and thread-local variables. Also, I present the Timer Framework, which leverages Thread behind the scenes to simplify timer-oriented tasks.

Thread Groups

While exploring the Thread class, you’ve probably encountered references to the java.lang.ThreadGroup class in constructors such as Thread(ThreadGroup group, Runnable target), and in methods such as static int ...

Get Java Threads and the Concurrency Utilities now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.