What is the Thread class?
Posted by Daisy WilliamsMar 8
The java.lang.Thread class is used to define a thread. The simplest way to create a thread by using the java.lang.Thread class is to take the following two steps:
Extend the java.lang.Thread class.
Override the run() method.
The extending class must override the run() method, which is the entry point of the new thread. The extending class calls the start() method to begin the execution of the new thread, as shown below:
class MyThread extends Thread
{
public void run()
{
System.out.println(”thread running”);
}
}
The major limitation of this approach is that if Thread is extended, the programmer will not be able to extend anything else.
No comments