December 2019
Intermediate to advanced
346 pages
9h 8m
English
A blocked thread relinquishes the processor slice for a specified amount of time. This improves performance by making it available for other threads but incurs the overhead of context switching. It is good in a scenario where the thread has to be blocked for a considerable amount of time. If the waiting time is less, it makes sense to go for spinning without relinquishing the processor slice. For example, the following code simply loops infinitely:
while(!done);
This is just an empty while loop that checks for a Boolean variable. When the wait is over, the variable will be set to false and the loop can break. Although this is a waste of processor time, it can significantly improve performance if the wait isn't very ...
Read now
Unlock full access