class thrun implements Runnable
{
Thread t;
boolean runn = true;
thrun(String st,int p)
{
t = new Thread(this,st);
t.setPriority(p);
t.start();
}
publicvoid run()
{
System.out.println("Thread name : " + t.getName());
System.out.println("Thread Priority : " + t.getPriority());
}
}
class priority
{
publicstaticvoid main(String args[])
{
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
thrun t1 = new thrun("Thread1",Thread.NORM_PRIORITY + 2);
thrun t2 = new thrun("Thread2",Thread.NORM_PRIORITY - 2);
System.out.println("Main Thread : " + Thread.currentThread());
System.out.println("Main Thread Priority : " + Thread.currentThread().getPriority());
}
}
/*
Output
Thread name : Thread1
Main Thread : Thread[main,10,main]
Thread name : Thread2
Thread Priority : 7
Main Thread Priority : 10
Thread Priority : 3
*/