GC: does Observable.addObserver() create a weak or strong reference?

Discussion in 'Java' started by Josef Garvi, May 27, 2004.

  1. Josef Garvi

    Josef Garvi Guest

    When I add an Observer to an Observable, will that produce a weak or a
    strong reference? By weak, I mean a reference of the type WeakReference,
    like in WeakHashMap that will not keep the GC from collecting my Observer.

    --
    Josef Garvi

    "Reversing desertification through drought tolerant trees"
    http://www.eden-foundation.org/

    new income - better environment - more food - less poverty
    Josef Garvi, May 27, 2004
    #1
    1. Advertising

  2. Josef Garvi

    Josef Garvi Guest

    Josef Garvi wrote:
    > When I add an Observer to an Observable, will that produce a weak or a
    > strong reference? By weak, I mean a reference of the type WeakReference,
    > like in WeakHashMap that will not keep the GC from collecting my Observer.


    The answer is no, as the Observable stores its Observers in a Vector, which
    is strong references.

    --
    Josef Garvi

    "Reversing desertification through drought tolerant trees"
    http://www.eden-foundation.org/

    new income - better environment - more food - less poverty
    Josef Garvi, May 27, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kuan Zhou
    Replies:
    1
    Views:
    4,987
    Paul Uiterlinden
    Jan 24, 2005
  2. Gabriel Zachmann

    strong/weak typing and pointers

    Gabriel Zachmann, Oct 28, 2004, in forum: Python
    Replies:
    102
    Views:
    1,780
    Carl Banks
    Nov 13, 2004
  3. j_mckitrick
    Replies:
    2
    Views:
    564
    Cameron Laird
    Nov 13, 2004
  4. John Nagle
    Replies:
    3
    Views:
    298
    John Nagle
    Feb 25, 2007
  5. Jason Cavett
    Replies:
    1
    Views:
    508
    Tom Hawtin
    Apr 19, 2007
Loading...

Share This Page