public class MyRun implements Runnable{//可以实现多个接口
private int first;
public MyRun(int first) {
this.first = first;
}
public void run() {
for(int i=first;i<=100;i+=2){
System.out.print(i+" ");
}
System.out.println();
}
}
public class MyThread {
public static void main(String[] args) {
Thread t1=new Thread(new MyRun(1));
t1.start();
Thread t2=new Thread(new MyRun(2));
t2.start();
for(int i=101;i<=200;i++){
System.out.print(i+" ");
}
System.out.println();
}
}
具体使用那种根据是否与多继承冲突