First of all, there are many cases where Sleep()
is misused, for example to "synchronize" threads or to regularily poll a value where a notification function would do (In Win32 WaitForSingleObject
for example)
But what about other use cases? Is Sleep
always evil? If no, what are good use cases for Sleep
? If yes, why do almost all languages have some kind of Sleep
statement?
PS: I've asked this question because of one of the comments of another question. There the OP states, that in his opinion, Sleep
is to be avoided like goto
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…