编辑代码

import java.util.*;



public class Main {



	public static void main(String[] args) {
        MyThread t1 = new MyThread("t1");
        MyThread t2 = new MyThread("t2");
        t1.setPriority(1);
        t2.setPriority(10);
        t1.start();
        t2.start();
        t1.join();
        t2.join();
	}
}

class MyThread extends Thread
{
    String who;
    public MyThread(String w)
    {
        who = w;
    }
	public void run()
	{
		while(true)
		{
            System.out.println(getPriority());
			System.out.println(who);
			try{sleep(1000);
			}catch(Exception e){}
		}
	}
}