Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
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: