A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Overloading of run() method

  1. Overloading of run() method is always possible, but thread class start() method can invoked no-argument run() method. 
  2. 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:












LEARN TUTORIALS

.

.