//ThreadPriority.java//主类ThreadPrioritypublic class ThreadPriority{public static void main(String argv[]){ //显示线程类的优先级常量System.out.println("MIN_PRIORITY:"+Thread.MIN_PRIORITY);System.out.println("MAX_PRIORITY:"+Thread.MAX_PRIORITY);System.out.println("NORM_PRIORITY:"+Thread.NORM_PRIORITY);//显示创建的两个线程的优先级MyThread1 t1=new MyThread1();MyThread2 t2=new MyThread2();System.out.println("MyThread t1 Priority:"+t1.getPriority());System.out.println("MyThread t2 Priority:"+t2.getPriority());t1.setPriority(2);t2.setPriority(6);System.out.println("MyThread t1 Priority:"+t1.getPriority());System.out.println("MyThread t2 Priority:"+t2.getPriority());//优先级设定后,启动线程的运行,观察输出t1.start();t2.start();}}//线程类MyThread1class MyThread1 extends Thread{public void run(){int i;for(i=0;i<10;i++) System.out.println("Thread1: "+i);System.out.println("Thread1 end");}}//线程类MyThread2class MyThread2 extends Thread{public void run(){int i;for(i=0;i<10;i++) System.out.println("Thread2: "+i);System.out.println("Thread2 end");}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。