Java Threads 2nd Ed.

Scott Oaks, Henry Wong

Publisher: O'Reilly, 1999, 319 pages

ISBN: 1-56592-418-5

Keywords: Java

Last modified: July 30, 2021, 5:45 p.m.

Thread's aren't a new idea: many operating systems and languages support them. Until Java, threads tended to be something that everyone talked about, but few used. Programming with threads was tricky and nonportable.

Not so with Java. Java's thread facilities are easy to use, and — like everything else in Java — are 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 of the classic Java Threads shows you how to take full advantage of Java's thread facilities, and brings you up to date with the latest changes in the thread interface for JDK 2. You'll learn where to use threads to increase efficiency, how to use them effectively, and how to avoid common mistakes. This book discusses problems like deadlock, race condition, and starvation in detail, helping you to write code without hidden bugs.

Java Threads, Second Edition, offers a thorough discussion of the Thread and ThreadGroup classes, the Runnable interface, and the language's synchronized operator. It explains how threads are scheduled on different platforms, and shows you how to develop a CPUScheduler class that implements your own scheduling policy. 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 showing how to implement thread pools and other synchronization techniques, 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, this new edition of 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.

  1. Introduction to Threading
    • Java Terms
    • Thread Overview
    • Why Threads?
    • Summary
  2. The Java Threading API
    • 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
    • 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
    • Static Methods (Synchronization Details)
    • Summary
  5. Useful Examples of Java Thread Programming
    • Data Structures and Containers
    • Simple Synchronization Examples
    • A Network Server Class
    • The AsyncInputStream Class
    • Using TCPServer with AsyncInputStreams
    • Summary
  6. Java Thread Scheduling
    • An Overview of Thread Scheduling
    • When Scheduling Is Important
    • Scheduling with Thread Priorities
    • Popular Scheduling Implementations
    • Native Scheduling Support
    • Other Thread-Scheduling Methods
    • Summary
  7. Java Thread Scheduling Examples
    • Thread Pools
    • Round-Robin Scheduling
    • Job Scheduling
    • Summary
  8. Advanced Synchronization Topics
    • Synchronization Terms
    • Preventing Deadlock
    • Lock Starvation
    • Thread-Unsafe Classes
    • Summary
  9. Parallelizing for Multiprocessor Machines
    • Parallelizing a Single-Threaded Program
    • Inner-Loop Threading
    • Loop Printing
    • Multiprocessor Scaling
    • Summary
  10. Thread Groups
    • Thread Group Concepts
    • Creating Thread Groups
    • Thread Group Methods
    • Manipulating Thread Groups
    • Thread Groups, Threads, and Security
    • Summary
  1. Miscellaneous Topics
  2. Exceptions and Errors

Reviews

Java Threads

Reviewed by Roland Buresund

Mediocre **** (4 out of 10)

Last modified: Nov. 15, 2008, 11:08 a.m.

Explains Java threads. So?

No book in this world is going to make Java's thread system to be useful.

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required