import java.util.*
/**
* <p>title: Increase thread priority </p>
* <p>description: By modifying the priority of the thread, Is the thread is given priority. </p>
* <p>copyright:copyright (c) 2003</p>
* <p>Filename:upPRIThread.java</p>
* @version 1.0
*/
public class Upprithread {
//Main method
public static void Main (string[] args) throws ption {
Thread1 t1 = new Thread1 ();
T1.start ();
Thread2 t2 = new Thread2 ();
T2.start ();
T1.setpriority (thread.min_priority);
T2.setpriority (thread.min_priority);
New Thread (). Sleep (105);
T2.setpriority (thread.max_priority);
New Thread (). Sleep (10500);
}
//Class Description: Thread 1, do not change precedence
Static class Thread1 extends Thread {
public void run () {
while (true) {
Try {
Thread.Sleep (100);
}
catch (Exception e) {
E.printstacktrace ();
System.out.println ("I am thread 111");
}
}
}
///Class Description: Thread 2, increasing priority
Static class Thread2 extends ThRead {
public void Run () {
while (true) {
try {
Thread.Sleep (MB);
catch (Exception e) {
E.printstacktrace ();
The
System.out.println ("I am a thread 222 ... .... ...");;......
}
}
}
}