OOP & Design Patterns - Observer Pattern - Event System, Publish-Subscribe
Suppose you want to extend the observer pattern to allow observers to receive multiple notifications for the same event type without unsubscribing (i.e., observers can be registered multiple times for the same event). Which modification to the thread-safe observer pattern implementation below correctly supports this requirement without breaking thread safety or notification correctness?
Options:
A) Change the observers data structure from a set to a list per event type and allow duplicates.
B) Keep using a set but add a counter for each observer to track multiple subscriptions.
C) Use a dictionary mapping observers to their subscription counts per event type.
D) Use a queue per event type to enqueue notifications and process them asynchronously.
