📄 thread1.java
字号:
public class therad1 extends Thread{
int no;
public therad1(int i){
no=i;
}
public void run(){
for(int i=0;i<7;i++){
System.out.println("Run thread"+ no+"="+i);
if(Thread.currentThread().getName().equals("t1"));{
Thread.yield();
/* try{
sleep(100);
}
catch(InterruptedException e){}*/
}
}
}
public static void main(String[] args) {
therad1 t1=new therad1(1);
therad1 t2=new therad1(2);
therad1 t3=new therad1(3);
t1.setPriority(Thread.MAX_PRIORITY);
t2.setPriority(Thread.MIN_PRIORITY);
t3.setPriority(Thread.MAX_PRIORITY);
t1.setName("t1");
t2.setName("t2");
t3.setName("t3");
t1.start();
t2.start();
t3.start();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -