thread.java
来自「java学习的作业 1.runnable和thread的使用区别 2.int」· Java 代码 · 共 38 行
JAVA
38 行
import java.lang.Thread;
class mythread extends Thread{
mythread(String str){
super(str);
this.start();
}
public void run(){
int i;
for(i=1;i<=5;i++)
{
System.out.println("subThread:"+i);
try{
sleep(100);
}
catch(InterruptedException e){
}
}
}
}
class mainthread extends Thread{
public static void main(String args[])
{
new mythread("subthread");
int i;
for(i=1;i<=5;i++)
{
System.out.println("mainthread:"+i);
try{
sleep(100);
}
catch(InterruptedException e){
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?