If there are too many observers, so the observed stream does not advance, then it would be wise to change the relationship. Instead of causing the observed stream to cause each observer, it might be better for the observers to wait for something like a condition variable or event associated with the observed stream. Then the observer code can be blocked, waiting for the condition variable to be signaled. The observed thread can then simply signal the condition variable, rather than ring the observer; observers can notice the signal and process the consequences in due time.
Anthony williams
source share