Creating three threads to run parallely.
class Thread1 extends Thread
{
Thread1(String s)
{
super(s);
}
public void run()
{
for(int i=0;i<5;i++)
System.out.println(getName());
}
}
Second Thread
class Thread2 extends Thread
{
Thread2(String s)
{
super(s);
}
public void run()
{
for(int i=0;i<10;i++)
System.out.println(getName());
}
}
Third Thread.
class Thread3 extends Thread
{
Thread3(String s)
{
super(s);
}
public void run()
{
for(int i=0;i<12;i++)
System.out.println(getName());
}
}
class RunThread extends Thread
{
public static void main(String... s)
{
Thread1 t1= new Thread1("Shalu");
Thread2 t2= new Thread2("Neo");
Thread3 t3= new Thread3("Shaleen");
t1.start();
t2.start();
t3.start();
for(int i=0;i<20;i++)
This line below..i.e.Thread.currentThread.getName() is showing error;
{
System.out.println(Thread.currentThread.getName());
}
}
}
The currentThread() is a valid method..then why it is howing error.