New threads can be defined using one of the following alternatives:

Thread instances that are defined using another approach are likely to have no effect.

To avoid empty thread instances, define new threads using one of the following alternatives:

In the following example, class Bad shows the definition of a thread that has no effect.

In the following example, class GoodWithOverride shows how to extend the Thread class and override its run method, and class GoodWithRunnable shows how to pass an argument of type Runnable to the constructor of the Thread class.

  • Java API Specification: Thread.
  • The Java Tutorials: Defining and Starting a Thread.