//上边的代码 还没修改完全 下边的 把多余的去掉了!还是 那2个地方出错!
import javax.swing.*;
class Priority implements Runnable
{
private int runtimes; public Priority()
{
runtimes = 0;
}
public int getdata()
{
return runtimes;
} public void run()
{
runtimes++;
}
}
class xian
{
public static void main(String[] args)
{
Thread hpThread,lpThread;
String output; Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
hpThread = new Thread(new Priority());
lpThread = new Thread(new Priority()); hpThread.setPriority(Thread.MAX_PRIORITY-2);
lpThread.setPriority(Thread.MAX_PRIORITY-3); hpThread.start();
lpThread.start(); try{
Thread.sleep(5000);
}
catch(InterruptedException e){
System.out.println("错误!主线程无法睡觉!");
}
hpThread.stop();
lpThread.stop();
try{
hpThread.join();
lpThread.join();
}
catch(InterruptedException e){
System.out.println("两个小线程回归大现成出错了!");
} output="优先的!"+hpThread.getdata()+"\n"+"不优先的!"+lpThread.getdata()+"\n";
JOptionPane.showMessageDialog(null,output);
System.exit(0);
}}//请帮我试试到底哪里错了!