Multithreading in java watch online session on youtube in Hindi)
How to create thread in javawatch online session on youtube in Hindi)
What is runtime stack in Java?watch online session on youtube in English)
Sleep Method in Java ?watch online session on youtube in English)
What is Java Lock? Or Synchronizationwatch online session on youtube in English)
What is Thread Group in Java?watch online session on youtube in English)
What will happen if we overload the run() method?
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 for overloading run method
{
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:
If we are not overriding run () method, then Thread class run() method will be executed. Which has empty implementation. Hence we won’t get any output.
Output:
no output