From another forum:
Member:
Moderator:
I LOL'd.
Member:
Quote:Would this be ok?
-- os.clock() returns an approximation of the amount of CPU
-- time used by the program, in seconds
function sleep(seconds)
time = os.clock()
while os.clock()-time < seconds do end
end
-- call sleep to sleep for 200 ms
sleep(0.2)
Moderator:
Quote:No. That is not ok. That's called "busy-waiting", and is the programming equivalent of burping into someone else's dinner. It will use 100% of CPU time, spinning wildly, until the wait is over. The sleep() function is in C for a reason: It allows you to wait without taking up all the computer's time doing it.
I LOL'd.