A similar solution is required fro your second loop - put a sleep in it. As it stands the loop will run just as fast as it can output stuff with print. That will be slower than an empty loop, but still pretty fast.
Another issue is that there is no way of stopping the 'alarm' loop. At the very least you should replace the while (1) with a down counter so it stops by itself eventually.
True laziness is hard work
|