File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes Removing self as a listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Removing self as a listener" Watch "Removing self as a listener" New topic

Removing self as a listener

Kenneth Winn

Joined: Apr 17, 2000
Posts: 8
What is the best way for an object to remove itself as a
listener of another object. It was added as a listener in
its ctor.
1) in the finalize method of the object?
2) create a new release() method that can be called by a third
object that 'has a' instance of the listening object?
3) other?
Thanks, Ken
Christope Roudet

Joined: Oct 12, 2000
Posts: 2
You can use WeakReferences in your listener container.
see Tip 79 in on JavaWorld
I agree. Here's the link:
subject: Removing self as a listener
It's not a secret anymore!