±Û¾´ÀÌ :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.
}