Skip to content
Sharp

Software Architecture · interview question

In a Java application using the Observer Pattern, how should you manage the list of observers to ensure thread safety?

Multiple choiceMediumchapter-13-curatedpremiumsoftware-architectureobserver-pattern
Choose one answer
Answer and explanation

Correct answer

D. Synchronize access to the observer list.

Why

Synchronizing access to the observer list ensures that additions, removals, and notifications are thread-safe. This prevents concurrent modifications that could lead to inconsistent states or exceptions.

Test yourself on Software Architecture

A free test with instant, explained results. No account needed.

Start free test
All Software Architecture questions →