class RunnableThread implements Runnable {
public void run(){
for (int i = 0;i<100;i++){
System.err.println((Thread.currentThread()).getName());
try{
(Thread.currentThread()).join();
}catch(Exception e){}
}
}
}
class MyThreadTest
{
public static void main(
String[] args)
{
RunnableThread r= new RunnableThread();
Thread t1= new Thread(r);
Thread t2= new Thread(r);
Thread t3= new Thread(r);
t1.start();
t2.start();
t3.start();
/*try{
//t1.join();
//t2.join();
// t3.join();
}catch(InterruptedException e){
} */
System.err.println("in main");
}
}
I am getting this output.
---------- intepreter ----------
in main
Thread-0
Thread-1
Thread-2