What Are Threads?

A unique property of Java is its built-in support for threads. Threads allow you to do many tasks simultaneously, or at least it seems that the tasks are working simultaneously. As you'll see later in this chapter, most of the time, there is actually only one thread running at a time. A thread is really nothing but a sequential flow of control within a program. In multithreaded programs, there are multiple flows of control. For the purposes of this chapter, a "flow of control" is referred to as a task.

If an application could only perform a new task when another task was completed, your applications would be severely limited. Fortunately, Java has built-in thread support that allows programmers to schedule multiple tasks to ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.