public class mainchild implements Runnable {
Thread t1;
public mainchild(String a) {
t1 = new Thread(this, a);
t1.start();
}
public void run() {
for (int x = 1; x <= 3; x++) {
System.out.println(x + " this thread is "
+ Thread.currentThread().getName());
}
}
public static void main(String[] args) {
mainchild mch = new mainchild("Child ");
for (int x = 1; x <= 3; x++) {
System.out.println(x + " this thread is "
+ Thread.currentThread().getName());
}
}
}
Output
1 this thread is main 1 this thread is Child 2 this thread is Child 3 this thread is Child 2 this thread is main 3 this thread is mainIf 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.