What is the easiest way to run some code each millisecond for a certain amount of time?

On AVRs, I've seen people enable one of the "Compare Match" interrupts on Timer0. This time is already running at about a 1ms rate (1/1024 s) till wrap-around, so any compare value will also interrupt every 1/1024 s. If you're not using PWM pins, you can set the compare register to an arbitrary value. If you ARE using PWM, whatever value is loaded by PWM will still cause an interrupt every 1/1024 s...

For example: Adafruit_GPS/shield_sdlog.ino at master · adafruit/Adafruit_GPS · GitHub