Skip to Main Content
Java Cookbook
book

Java Cookbook

by Ian F. Darwin
June 2001
Intermediate to advanced content levelIntermediate to advanced
888 pages
21h 1m
English
O'Reilly Media, Inc.
Content preview from Java Cookbook

Chapter 24. Threaded Java

Introduction

We live in a world of multiple activities. A person may be talking on the phone while doodling or reading a memo. A FAX machine may scan one FAX while receiving another and printing a third. We expect the GUI programs we use to be able to respond to a menu while updating the screen. But ordinary computer programs can do only one thing at a time. The conventional computer programming model -- that of writing one statement after another, punctuated by repetitive loops and binary decision-making -- is sequential at heart.

Sequential processing is straightforward, but not as efficient as it could be. To enhance performance, Java offers threading, the capability to handle multiple flows of control within a single application or process. Java provides thread support and, in fact, requires threads: the Java runtime itself is inherently multithreaded. For example, Windows system action handling and Java’s garbage collection -- that miracle that lets us avoid having to free everything we allocate, as we must do when working in languages at or below C level -- run in separate threads.

While most modern operating systems -- POSIX P1003, Sun Solaris, the Distributed Computing Environment (OSF/DCE) for Unix, Windows NT/95, and MacOS -- provide threads, Java is the first mainstream programming language to have intrinsic support for threaded operations built right into the language. The semantics of java.lang.Object, of which all objects are instances, includes ...

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

Practical Cloud-Native Java Development with MicroProfile

Practical Cloud-Native Java Development with MicroProfile

Emily Jiang, Andrew McCright, John Alcorn, David Chan, Alasdair Nottingham
Distributed Computing in Java 9

Distributed Computing in Java 9

Raja Malleswara Rao Malleswara Rao Pattamsetti

Publisher Resources

ISBN: 0596001703Supplemental ContentCatalog PageErrata