Thread creation, in the context of Java, occurs either by extending the thread class or implementing the runnable interface.
In Java, an object of the thread class represents a thread. When a thread is first created, it must be permenantly bound to an object with a run() method; when invoked, it should invoke the object's run() method.
Implementing the runnable interface involves the following steps:
Extending the thread class involves the following steps:
The runnable interface is generally preferred over extending the thread class for two reasons:
Read More »
Get Techopedia delivered to your inbox!