Yes. It must be either a subclass of Thread, or implement Runnable, or be both. Thread API:
There are two ways to create a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started. The other way to create a thread is to declare a class that implements the Runnable interface. That class then implements the run method. An instance of the class can then be allocated, passed as an argument when creating Thread, and started.
Joined: Aug 24, 2003
Hi Vad, Actually the target does not even have to be a subclass of Thread. Thread a = new Thread(); Thread b = new Thread (a); The works just fine. Thanks.
Joined: Aug 25, 2003
Right, but if it's not, then the new thread is useless because its run() method is not overridden.