- Overloading of run() method is always possible, but thread class start() method can invoked no-argument run() method.
- The other overloaded method, we have to call explicitly like a normal method call.
Program
of overloading
Class MyThread
extends Thread
{
Public
void run()
{
System.out.println(“no-arg
run”);
}
Public
void run(int
i)
{
System.out.println(“int-arg
run”);
}
}
Class Test
{
Public
static void main(String[]args)
{
MyThread t =new MyThread();
t.start()
}
}
output: