public class Test { public static void main(String[] args) { MyThread m1 = new MyThread("m1"); MyThread m2 = new MyThread("m2"); m1.start(); m2.start(); } } class MyThread extends Thread { MyThread(String s) { super(s); } public void run() { for(int i = 1; i <= 100; i++) { System.out.println(getName() + ": " + i); if(i % 10 == 0) {//每次被10整除后高风亮节的让出时间片 yield(); } } } }