loop for a certain period of time

Hey people,
I need some help with my multiplexer, i want to ask is there a way to make a loop to do something for a specified amount of time? I suppose with counters it is also possible but isn't there a way to do like

while(10 seconds not passed)
something;

i suppose i can use a timer that would count an integer to 10 each second +1, and use a loop like

while(integer that is used by the timer <= 10)
something;

Possible? or am i asking something stupid?

unsigned long startTime = millis();
unsigned long interval = 10000UL; // 10 seconds

while(millis() - startTime < interval)
{
  // Do whatever
}

thanks, i really owe ya