Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8025077

Documentation of java.util.Observable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 7
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      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.

        Issue Links

          Activity

          Hide
          smarks Stuart Marks added a comment -
          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.
          Show
          smarks Stuart Marks added a comment - 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.

            People

            • Assignee:
              smarks Stuart Marks
              Reporter:
              coffeys Sean Coffey
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: