글쓴이 :Sung 2000년 2월 09일 02:16:56
In Reply to: 소스 부탁드립니다. posted by 야키 on 2000년 2월 08일 15:39:52:
Your base class should extend Thread.
Start the thread by "new YourClass().start()".
In the run() method in YourClass,
===========================================
public void run() {
//sleep for 5 seconds and wake up
while(true){
try{
sleep(5000);
System.out.println("Woke up");
stop();
//do something
}
catch(IllegalThreadStateException itx){
}
catch(InterruptedException itx){
}
}
}
==============================================
-Or-
If you want to create a selfish method to wait then,
public void pause(int delay) {
long s = System.currentTimeMillis();
long sleepTime = delay * 1000;
while(System.currentTimeMillis() < (s + sleepTime));
//do something.
}