public class MyTimer extends Thread{ public TimeOut it; private float timeLimit; MyTimer(TimeOut that, float limit){ it = that; timeLimit = limit; } public void run(){ long startTime = System.currentTimeMillis(); while(((float)(System.currentTimeMillis() - startTime) < timeLimit) ){ try{ sleep(100); }catch(InterruptedException e){ } } it.set_time(1); } }