JDK-8025077 : Documentation of java.util.Observable
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2013-02-19
  • Updated: 2016-04-20
  • Resolved: 2016-04-20
Related Reports
Relates :  
Description
A DESCRIPTION OF THE REQUEST :
The documentation of java.util.Observable doesn't say if it's safe for multiple threads to call its public methods (e.g., notifyObservers) on a shared instance.

JUSTIFICATION :
It complicates programming to have to synchronize calls to notifyObservers, especially when the callback does not require any explicit synchronization.
Comments
Observable in fact does internal synchronization, so it is *probably* thread safe under most circumstances. However, its documentation already states that various methods can be overridden by subclasses, and that event notification can occur in different orders and possibly on different threads. That is enough to disrupt any "thread safety" assertions that could be made about Observable. Observer and Observable will be deprecated by JDK-8154801. It's not worth trying to refine the specifications of these classes. Closing as Won't Fix.
20-04-2016