Maybe I am doing it the wrong way, but: Why you don't use millis() instead?
I mean, when you set led1 ON, you do:
digitalWrite(led1,HIGH);
time1=millis();
and for example if you want it ON for 250 ms:
if (millis>time1+250){
digitalWrite (led1,LOW);}
This way the loop it's never stopped.
NO?