I
Inertia_sublimation
Hello everyone. Im attempting to make a very simple multithreaded application.
The problem Im having is deciding what kind of collection I need to use to hold
classes that have methods triggered asynchronously. Eg: Class A implements
FooListener, foo.addFooListener(anInstanceOfA) stores anInstanceOfA in one of
foo's fields. I need to figure out what type of collection is best for that.
I just recently downloaded Tiger, and took a look at what changed in the
Collections API. I was extatic about the new for-loop functionality and
generics, but noticed something even more interesting, as it seemed to pertain
to extactly what I wanted to do: CopyOnWriteArraySet.
CopyOnWriteArraySet's JavaDoc says its ideal to use for my purposes. Before
encountering this, I was strongly considering taking the advice of the author of
Hardcore Java, who recommends a WeakHashSet.
What should I do? Should I use one over another? Should I subclass
CopyOnWriteArraySet and make a WeakCopyOnWriteArraySet? What are the benefets of
each decision?
Thanks in advance!
The problem Im having is deciding what kind of collection I need to use to hold
classes that have methods triggered asynchronously. Eg: Class A implements
FooListener, foo.addFooListener(anInstanceOfA) stores anInstanceOfA in one of
foo's fields. I need to figure out what type of collection is best for that.
I just recently downloaded Tiger, and took a look at what changed in the
Collections API. I was extatic about the new for-loop functionality and
generics, but noticed something even more interesting, as it seemed to pertain
to extactly what I wanted to do: CopyOnWriteArraySet.
CopyOnWriteArraySet's JavaDoc says its ideal to use for my purposes. Before
encountering this, I was strongly considering taking the advice of the author of
Hardcore Java, who recommends a WeakHashSet.
What should I do? Should I use one over another? Should I subclass
CopyOnWriteArraySet and make a WeakCopyOnWriteArraySet? What are the benefets of
each decision?
Thanks in advance!