When observers need updates at different times, the plain Observer pattern's synchronous, immediate notifyObservers() is not enough. You extend it with prioritization, scheduling, or queuing so each observer receives updates according to its own timing requirements rather than all at once.
A stock price subject might notify a real-time trading dashboard immediately, but batch updates every five minutes for a reporting observer, using separate notification paths keyed by observer type.
import java.util.ArrayList;
import java.util.List;
public class StockObservers {
interface PriceObserver { void onPrice(String symbol, double price); }
// Immediate observer
static class Dashboard implements PriceObserver {
public void onPrice(String s, double p) { System.out.println("Dashboard (live): " + s + " " + p); }
}
// Buffers updates and flushes them on its own schedule
static class BatchReport implements PriceObserver {
private final List<String> buffer = new ArrayList<>();
public void onPrice(String s, double p) { buffer.add(s + "=" + p); }
void flush() {
System.out.println("Report (batched every 5 min): " + buffer);
buffer.clear();
}
}
static class StockTicker {
private final List<PriceObserver> observers = new ArrayList<>();
void add(PriceObserver o) { observers.add(o); }
void price(String symbol, double p) { observers.forEach(o -> o.onPrice(symbol, p)); }
}
public static void main(String[] args) {
StockTicker ticker = new StockTicker();
BatchReport report = new BatchReport();
ticker.add(new Dashboard());
ticker.add(report);
ticker.price("INFY", 1510.5);
ticker.price("INFY", 1512.0);
report.flush(); // in production a ScheduledExecutorService would call this
}
}Dashboard (live): INFY 1510.5
Dashboard (live): INFY 1512.0
Report (batched every 5 min): [INFY=1510.5, INFY=1512.0]
A concise interview answer is
When observers have different update needs, I don't rely on a single synchronous notifyObservers() call — I add prioritization or route updates through a queue or scheduler so each observer gets notified on its own cadence. That keeps fast, critical observers responsive without forcing slower ones to process every single update.
Last updated: 1 November 2026
Previous question: What are the differences between the Observer pattern and the Pub/Sub model?
Next question: What are the challenges of using the Observer pattern in multithreaded environments?