📄 threadpropdemo.java
字号:
package chapter13;
public class ThreadPropDemo extends Thread {
ThreadPropDemo(String name) {
super(name);
}
public static void main(String args[]) throws Exception {
ThreadPropDemo thread1 = new ThreadPropDemo("线程1");
ThreadPropDemo thread2 = new ThreadPropDemo("线程2");
ThreadPropDemo thread3 = new ThreadPropDemo("线程3");
thread3.setPriority(Thread.MAX_PRIORITY);
thread1.setPriority(1);
thread1.start();
thread2.start();
thread3.start();
}
public void run() {
for (int i = 0; i < 3; i++) {
System.out.println(getName() + "的优先级为:" + getPriority());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -