文档介绍:Java Threads, 2nd edition
Scott Oaks & Henry Wong
2nd Edition January 1999
ISBN: 1-56592-418-5, 332 pages
Revised and expanded to cover Java 2, Java Threads shows you how to
take full advantage of Java's thread facilities: where to use threads to
increase efficiency, how to use them effectively, and how to avoid
common mistakes.
It thoroughly covers the Thread and ThreadGroup classes, the Runnable
interface, and the language's synchronized operator.
The book pays special attention to threading issues with Swing, as well
as problems like deadlock, race condition, and starvation to help you
write code without hidden bugs.
Table of Contents
Preface 1
1. Introduction to Threading 5
Java Terms
Thread Overview
Why Threads?
Summary
2. The Java Threading API 12
Threading Using the Thread Class
Threading Using the Runnable Interface
The Life Cycle of a Thread
Thread Naming
Thread Access
More on Starting, Stopping, and Joining
Summary
3. Synchronization Techniques 31
A Banking Example
Reading Data Asynchronously
A Class to Perform Synchronization
The Synchronized Block
Nested Locks
Deadlock
Return to the Banking Example
Synchronizing Static Methods
Summary
4. Wait and Notify 50
Back to Work (at the Bank)
Wait and Notify
wait(), notify(), and notifyAll()
wait() and sleep()
Thread Interruption
Static Methods (Synchronization Details)
Summary
5. Useful Examples of Java Thread Programming 64
Data Structures and Containers
Simple Synchronization Examples
work Server Class
The AsyncInputStream Class
Using TCPServer with AsyncInputStreams
Summary
6. Java Thread Scheduling 87
An Overview of Thread Scheduling
When Scheduling Is Important
Scheduling with Thread Priorities
Popular Scheduling Implementations
Native Scheduling Support
Other Thread-Scheduling Methods
Summary