阅读下列程序,请写出该程序的输出结果。
class MyThread extends Thread
String message,int s;
MyThread(String message,int sec)this. message=message;s=sec;
public void run()
trysleep(s);catch(InterruptedException e)
System. out. println(message+" "+getPriority());
class ThreadTest
public static void main(String args[])
Thread foo=new MyThread("Foo",1000);
foo. setPriority(Thread.MIN_PRIORITY);foo.start();
Thread bar=new MyThread("Bar",800);
bar.setPriority(3);bar.start();
Thread gar=new MyThread("Gar",400);
gar. setPriority(7);gar.start();
Thread kar=new MyThread("Kar",100);
kar. setPriority(Thread.MAX_PRIORITY);kar.start();
注:假设处理机中没有其他线程占用资源。
参考答案:Kar 10
Gar 7
Bar 3
Foo 1