16.5. Thread Methods

The following subsections summarize the constructors, constants, and methods in the Thread class. Included also are the wait, notify, and notifyAll methods (which really belong to Object, not just to Thread).

Constructors

public Thread()

Using this constructor on the original Thread class is not very useful because once started, the thread will call its own run method, which is empty. However, a zero-argument constructor is commonly used for thread subclasses that have overridden the run method. Calling new Thread() is equivalent to calling new Thread(null, null, "Thread-N"), where N is automatically chosen by the system.

public Thread(Runnable target)

When you create a thread with a Runnable as a target, the target's run method ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.