
My question is why it is needed to pass this keyword to the thread constructor eventhough we had created only one thread and if you say we have added to point to the current thread then why we have not added this in the following line "s=s1" Pls reply......
class MyThread extends Thread { Thread t; String s; MyThread(String s1) { s=s1; t=new Thread(this);//Point of concern t.start(); } public void run() { System.out.println(s); } }
public class ThreadDemo { public static void main(String [] args) { MyThread m=new MyThread("Thread Started...."); } }
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.