This is a code snippet.
class Thread1 extends Thread
{
Thread1(String s)
{
super(s);
}
public void run()
{
for(int i=0;i<5;i++)
System.out.println(getName());
}
}
I have created Three different classes for three threads.
class Thread2 extends Thread
{
Thread2(String s)
{
super(s);
}
public void run()
{
for(int i=0;i<10;i++)
System.out.println(getName());
}
}
class Thread3 extends Thread
{
Thread3(String s)
{
super(s);
}
public void run()
{
for(int i=0;i<12;i++)
System.out.println(getName());
}
}
Simply trying to print the name of the thread as per the priority set by me.
class RunThread extends Thread
{
public static void main(String... s)
{
Thread1 t1= new Thread1("T1");
Thread2 t2= new Thread2("T2");
Thread3 t3= new Thread3("T3");
but this threads are printing in the same random way..as they are printed when no priority is set.
t1.setPriority(Thread.NORM_PRIORITY);
t2.setPriority(Thread.MIN_PRIORITY);
t3.setPriority(Thread.MAX_PRIORITY);
}
}