while($runningtime<$maxtime) { dosomething(); }