Yielding to Other Threads
You learned earlier about thread starvation. To refresh, thread starvation occurs when one or more threads are not getting enough attention from the CPU. There are several reasons this might occur:
Incorrect thread priorities
Staying too long in a sleep method
Other threads not yielding correctly
The first two possible reasons have already been discussed in previous sections of this chapter, so now focus on the third possibility: incorrect yielding. You can think of a thread yielding as "being a good citizen." Just because a thread has been given a high prioritydoes not mean that it should always have access to the CPU for performing its tasks. It sometimes needs to back away and let other threads have a chance. When the ...
Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.