public class Test {
public static void main(String[] args) {
Runner runner = new Runner();
Thread t = new Thread(runner);
t.start(); //调用start()方法来启动线程s
runner.run(); //直接通过类调用类中的方法来启动线程
}
}
class Runner implements Runnable {
public void run() {
for(int i=0;i<10;i++){
System.out.println("i = "+i);
}
}
}