//创建线程示例
public class ThreadPriority implements Runnable {
@Override
public void run() {
for(int i = 0;i<5;i++) {
System.out.println(Thread.current().getName()+"输出"+i);
}
}
public static void main(String[] args) {
Thread maxPriority = new Thread(new ThreadPriority(),"高优先级线程");
Thread minPriority = new Thread(new ThreadPriority(), "低优先级线程");
maxPriority.setPriority(Thread.MAX_PRIORITY);//高优先级线程
minPriority.setPriority(Thread.MAX_PRIORITY); //低优先级线程
maxPriority. start();
minPriority.start();
}
}
已有 22658 名学员学习以下课程通过考试
最需教育客户端 软件问题一手掌握
去 App Store 免费下载 iOS 客户端
点击加载更多评论>>