|
-
Nov 4th, 2011, 10:25 AM
#9
Re: Timer delay
DON'T USE THAT CODE!!!!
Yes, it WILL pass compile, and it will even work as you expect, but that doesn't mean it's a good idea. Making use of a busy wait like that will have physical consequences, which isn't something that can be said about most programs.
It seems like there is somebody suggesting a busy wait whenever anybody asks for a way to pause without using thread.sleep (which has other problems). A busy wait is so easy to implement that people don't have any difficultly making it work. What they don't understand is that it is downright harmful. While that loop is running, your CPU will be absolutely pegged out. That's a nasty thing to do to people even if you have multiple cores, because that core is fully occupied doing absolutely nothing. You aren't really waiting, you are frantically busy running in place. The two are not the same.
I can't make it any more plain: That code will work, but DON'T USE IT!!!
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|