busy waiting

Author: yifei / Created: July 28, 2017, 7:34 a.m. / Modified: July 28, 2017, 3:35 p.m. / Edit

while True: pass

this is busy waiting

while True: time.sleep(10)

this is not busy waiting, bucause cpu are free to do other things, and only need trivial cpu cycles


busy waiting is considered as anti-pattern, but using it in spinning-lock is ok

should use select if we need to wait for something