62,614
社区成员
发帖
与我相关
我的任务
分享
package zz_text;
public class TestII {
public static void main(String[] args) {
MyThread t1 = new MyThread("t1");
t1.start();
for (int i = 0; i < 100; i++) {
System.out.println("MainThread " + i);
}
}
}
class MyThread extends Thread{
public MyThread(String name) {
super(name);
}
public void run() {
for (int i = 0; i < 100; i++) {
System.out.println(getName() + "\t" + i);
if (i % 5 == 0) {
yield();
}
}
}
}