Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
Thread t = Thread.currentThread();
System.out.println(t);
NewPriority hipri = new NewPriority(Thread.NORM_PRIORITY + 2);
NewPriority lopri =new NewPriority(Thread.NORM_PRIORITY - 2);
lopri.start();
hipri.start();
try
{
Thread.sleep(10000);
}
catch(InterruptedException e)
{
System.out.println("Main thread interrupted.");
}
lopri.stop();
hipri.stop();
try
{
// Instruct main thread to wait for other threads to finish
hipri.rt.join();
lopri.rt.join();
}
catch(InterruptedException e)
{
System.out.println("Interupt exception caught");
}
System.out.println("low priority thread: " + lopri.click);
System.out.println("High priority thread: " + hipri.click);