[JDEV] Use of IdentifierCounter

Gerry Wheeler gwheeler at vmguys.com
Thu Feb 8 11:01:15 CST 2001


I'm confused about how to use
org.jabber.jabberbeans.IdentifierCounter.

When I first looked at the Javadocs, I saw that the initial value
could be set by the constructor. So, I created two instances (each in
a separate thread) with different initial values. I started seeing
funny behaviour, though, where one thread would start using values
that should be part of the other thread.

I looked at the source code and found that the internal storage of the
current value is *static*, which means that all instances will use the
same counter!

Suggestion: Please document this in the Javadocs for the class.

Question: Why would it be done that way? Why not keep the counter in
an instance variable, so different instances could have different
counts. Alternatively, if you really want the static counter, why
initialize it in a constructor? Why not have a static method to set
the counter?

Gerry






More information about the JDev mailing list