Home Page Icon
Home Page
Table of Contents for
Java Threads, 2nd Edition
Close
Java Threads, 2nd Edition
by Henry Wong, Scott Oaks
Java Threads, Second Edition
Java Threads, 2nd Edition
Preface
Who Should Read This Book?
Versions Used in This Book
Organization of This Book
Conventions Used in This Book
Feedback for Authors
Acknowledgments
1. Introduction to Threading
Java Terms
Thread Overview
Overview of Multitasking
Overview of Multithreading
Why Threads?
Nonblocking I/O
Alarms and Timers
Independent Tasks
Parallelizable Algorithms
Summary
2. The Java ThreadingAPI
Threading Using the Thread Class
Animate Applet
Stopping a Thread
Threading Using the Runnable Interface
The Life Cycle of a Thread
The isAlive() Method
Joining Threads
Thread Naming
Thread Access
The Current Thread
Enumerating Threads in the Virtual Machine
More on Starting, Stopping, and Joining
Summary
3. Synchronization Techniques
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
Back to Work (at the Bank)
Wait and Notify
wait(), notify(), and notifyAll()
wait() and sleep()
Thread Interruption
Interrupted I/O
Static Methods (Synchronization Details)
Summary
5. Useful Examplesof Java Thread Programming
Data Structures and Containers
The Message Queue
Shared Memory
The Circular Linked List
Synchronization and Efficiency
Simple Synchronization Examples
Barrier
Condition Variables
A Network Server Class
The AsyncInputStream Class
Using TCPServer with AsyncInputStreams
Summary
6. Java Thread Scheduling
An Overview of Thread Scheduling
Scheduling Example: Threads of Different Priorities
Scheduling Equal-Priority Threads
Priority Inversion and Inheritance
Round-Robin Scheduling
Threading Models
When Scheduling Is Important
Round-Robin Scheduling and “Fairness”
Scheduling with Thread Priorities
Priority-Related Calls in the Java API
Using the Priority Calls
When to Use Simple Priority-Based Calls
Popular Scheduling Implementations
Green Threads
Scheduling of green threads
Windows Native Threads
Scheduling of Windows native threads
Solaris Native Threads
Scheduling of Solaris native threads
LWPs in the virtual machine
Native Scheduling Support
Implementing CPUSupport on Windows
Implementing CPUSupport on Solaris
Other Thread-Scheduling Methods
The suspend() and resume() Methods
Alternatives to the suspend() and resume() methods
The yield() Method
Yielding versus priority-based scheduling
Daemon Threads
Summary
7. Java Thread Scheduling Examples
Thread Pools
Round-Robin Scheduling
A Simple Round-Robin Scheduler
A More Complete Scheduler
Adjustment 1: Synchronizing data within the CPUScheduler
Adjustment 2: Making CPUScheduler thread safe
Adjustment 3: More thread-safe modifications
Adjustment 4: Devising an exit mechanism
Adjustment 5: Non-CPU-intensive threads
Job Scheduling
Summary
8. Advanced Synchronization Topics
Synchronization Terms
Preventing Deadlock
Another Type of Deadlock
Lock Starvation
Reader-Writer Locks
Priority-Inverting Locks
Thread-Unsafe Classes
Explicit Synchronization
Explicit synchronization and native code
Single-Thread Access
Using the Java Foundation Classes
The event-dispatching thread and event-related method
The invokeAndWait() method
The invokeLater() method
The repaint() method
Other thread-unsafe classes
Summary
9. Parallelizing for Multiprocessor Machines
Parallelizing a Single-Threaded Program
Loop Scheduling and Load Balancing
Variable Classifications
Loop-private variables
Read-only variables
Storeback variables
Reduction variables
Shared variables
Loop Analysis and Transformations
Loop distribution
Loop isolation
Loop interchange
Loop reimplementation
Inner-Loop Threading
Loop Printing
Multiprocessor Scaling
Summary
10. Thread Groups
Thread Group Concepts
Creating Thread Groups
Thread Group Methods
Finding Thread Groups
Enumerating Thread Groups
Thread Group Priority Calls
Destroying Thread Groups
Daemon Thread Groups
Miscellaneous Methods
Manipulating Thread Groups
Thread Groups, Threads, and Security
Summary
A. Miscellaneous Topics
Thread Stack Information
General Thread Information
Default Exception Handler
The ThreadDeath Class
Inheriting from the ThreadDeath Class
More on Thread Destruction
The Volatile Keyword
B. Exceptions and Errors
InterruptedException
InterruptedIOException
NoSuchMethodError
RuntimeException
IllegalThreadStateException
IllegalArgumentException
IllegalMonitorStateException
NullPointerException
SecurityException
Arbitrary Exceptions
Index
Colophon
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Cover
Next
Next Chapter
Preface
Java Threads, 2nd Edition
Scott Oaks
Henry Wong
Editor
Mike Loukides
Copyright © 1999 O'Reilly Media, Inc.
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset