I confuse between thread.run() && thread.start() methods because
thread.start() --> start new thread so name of thread is changed (obviously)
thread.run() --> does not start new thread (run on main thread) though according to below program thread's name is changed.
Why god why?
public class DemoClass {
public static void main(String[] z) {
Thread t = Thread.currentThread();
System.out.println("Main thread : " + t.getName());
MyThread thread = new MyThread();
thread.run();
thread.start();
}
}
public class MyThread extends Thread {
public void run() {
System.out.println("Important job running in MyThread");
System.out.println("run : " + this.getName());
}
}
O/p :
Main thread : main
Important job running in MyThread
run : Thread-0
Important job running in MyThread
run : Thread-0
Please correct me if i am wrong to some concept.