I have a Java program with a blocking queue that is being populated very quickly. There are several threads that take objects from the queue and process them.
Because the new objects are generated quickly, the consuming threads don't get a chance to wait for the queue to contain an object, there is always an object waiting.
Is it recommended/needed to sleep()
inside the loop of the consuming threads in order to let other processes on the machine get CPU time?
If not, because OS is taking care of time-sharing, how does it happen that a system becomes unresponsive or very slow when intensive processes are running on it?
Clarification
I'm asking about other processes on the system, not about the other threads of the Java program.