sleep方法
public class Test{
public static void main(String[] args) {
MyThread t = new MyThread();
t.setName("t");
t.start();
try {
t.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("hello world");
}
}
class MyThread extends Thread{
@Override
public void run() {
for (int i = 0; i < 10000; i++) {
System.out.println("额外线程------>"+i);
}
}
}
最后输出“hello world”