Skip to Main Content
Java Threads, 3rd Edition
book

Java Threads, 3rd Edition

by Scott Oaks, Henry Wong
September 2004
Intermediate to advanced content levelIntermediate to advanced
362 pages
11h 24m
English
O'Reilly Media, Inc.
Content preview from Java Threads, 3rd Edition

Chapter 14. Thread Performance

In a few places in this book, we’ve referred to performance characteristics of thread-related programming. We’ve glossed over a lot of that information; in this chapter, we’ll look at these performance issues in more depth. In particular, we’ll look at thread creation performance, the performance advantages of using a thread pool, and the real costs of synchronization. However, we’ll start with an overview of factors that affect Java performance.

Overview of Performance

Most developers are concerned about the performance of their program. Even though there are many programs for which performance doesn’t really matter, no one wants to write a badly performing program. And there are many more programs for which performance is crucial.

Performance, however, is not the most important aspect in developing good programs. We’ve frequently met developers who allow their concerns about performance to complicate their program development: for example, believing that synchronization is inherently expensive, they may spend days attempting to write a class that doesn’t need synchronization. The resulting code is complex, difficult to maintain, and more prone to bugs than a simpler (in this case, synchronized) version.

Without any prior knowledge of a program’s behavior, this is counterproductive. Developer time is wasted, and support costs are increased. This observation leads us to our first rule of performance: premature optimization is the root of much evil.[1

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Performance: The Definitive Guide

Java Performance: The Definitive Guide

Scott Oaks
Java Concurrency, 2/e

Java Concurrency, 2/e

Douglas Schmidt
Java Swing, 2nd Edition

Java Swing, 2nd Edition

Dave Wood, Robert Eckstein, Marc Loy, James Elliott, Brian Cole

Publisher Resources

ISBN: 0596007825Supplemental ContentErrata Page