62,620
社区成员
发帖
与我相关
我的任务
分享public class SecondThread implements Runnable{
int i = 0;
public void run() {
for(i = 0;i < 50;i++){
System.out.println(Thread.currentThread().getName() + ":" + i);
}
}
public static void main(String[] args) {
for(int i = 0;i<50;i++){
System.out.println(Thread.currentThread().getName()+":"+i);
if(i == 20){
Runnable target = new SecondThread();
new Thread(target, "task1").start();
new Thread(target, "task2").start();
}
}
}
}