O'Reilly - Java Threads (1999).pdf
(
1289 KB
)
Pobierz
Java Threads, 2nd edition
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
A Network 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
Table of Contents (cont...)
7. Java Thread Scheduling Examples
117
Thread Pools
Round-Robin Scheduling
Job Scheduling
Summary
8. Advanced Synchronization Topics
137
Synchronization Terms
Preventing Deadlock
Lock Starvation
Thread-Unsafe Classes
Summary
9. Parallelizing for Multiprocessor Machines
162
Parallelizing a Single-Threaded Program
Inner-Loop Threading
Loop Printing
Multiprocessor Scaling
Summary
10. Thread Groups
189
Thread Group Concepts
Creating Thread Groups
Thread Group Methods
Manipulating Thread Groups
Thread Groups, Threads, and Security
Summary
A. Miscellaneous Topics
203
B. Exceptions and Errors
209
Colophon
214
Description
Threads aren't a new idea: many operating systems and languages support them. But despite
widespread support, threads tend to be something that everyone talks about, but few use.
Programming with threads has a reputation for being tricky and nonportable.
Not so with Java. Java's thread facilities are easy to use, and - like everything else in Java - are
completely portable between platforms. And that's a good thing, because it's impossible to write
anything but the simplest applet without encountering threads. If you want to work with Java, you
have to learn about threads.
This new edition 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.
Java Threads
discusses problems like deadlock, race condition, and starvation in detail, helping you
to write code without hidden bugs. It brings you up to date with the latest changes in the thread
interface for JDK 1.2.
The book offers a thorough discussion of the Thread and ThreadGroup classes, the Runnable
interface, the language's synchronized operator. It explains thread scheduling ends by developing a
CPUSchedule class, showing you how to implement your own scheduling policy. In addition,
Java
Threads
shows you how to extend Java's thread primitives. Other extended examples include classes
that implement reader/writer locks, general locks, locks at arbitrary scope, and asynchronous I/O.
This edition also adds extensive examples on thread pools, advanced synchronization technique, like
condition variables, barriers, and daemon locks. It shows how to work with classes that are not thread
safe, and pays special attention to threading issues with Swing. A new chapter shows you how to write
parallel code for multiprocessor machines.
In short,
Java Threads
covers everything you need to know about threads, from the simplest
animation applet to the most complex applications. If you plan to do any serious work in Java, you will
find this book invaluable. Examples available online. Covers Java 2.
Plik z chomika:
Witek63
Inne pliki z tego folderu:
Wrox - J2EE Design Patterns Applied (Chapter 5) (2002).pdf
(1437 KB)
Wrox - Professional J2EE with BEA WebLogic Server (2000).pdf
(4123 KB)
Wrox - J2EE Design Patterns Applied (Chapter 3) (2002).pdf
(535 KB)
Wrox - Expert One-on-One - J2EE Development without EJB (2004).pdf
(8141 KB)
Wordware - JBuilder 8.0 - JFC and Swing Programming (2003).pdf
(6648 KB)
Inne foldery tego chomika:
C ++ - programowanie - kurs video PL (video tutorial PL)
C++ Programowanie PL
C++ Qt Programming
CodeIgniter
Complete IT Books Pack
Zgłoś jeśli
naruszono regulamin