日期:2014-05-20 浏览次数:21147 次
public class SleepTest {
public static void main(String[] args) throws InterruptedException {
SleepThread st = new SleepThread();
st.start();
while (true) {
st.sleep(3000);
System.out.println("main thread.");
}
}
static class SleepThread extends Thread {
@Override
public void run() {
while (true) {
System.out.println("not sleep.");
}
}
}
}
public class SleepTest {
public static void main(String[] args) throws InterruptedException {
SleepThread st = new SleepThread();
st.sleep(3000);
st.start();
System.out.println("main thread.");
}
static class SleepThread extends Thread {
@Override
public void run() {
while (true) {
System.out.println("not sleep.");
}
}
}
}