4 ms·
Schedule a timer, and respond to the timer events. Its a waste of resources to have a thread hanging around sleeping all the time.
by winstonewert 9y ago
Schedule a timer, and respond to the timer events. Its a waste of resources to have a thread hanging around sleeping all the time.
- jdmichal 9y agoThis is basically "There is no Thread": https://blog.stephencleary.com/2013/11/there-is-no-thread.html https://blog.stephencleary.com/2013/11/there-is-no-thread.ht... There are times when you can offload an asynchronous task to non-CPU hardware, in which case the blocking thread can disappear. The thread reappears when the hardware asynchronously informs the CPU of task completion. (This idea is what Node.JS is entirely reliant upon.) Consider if we didn't have timing hardware to handle this task for us. We could implement a timer with a spin-loop thread which checks the clock and fires off events.