commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@gmail.com>
Subject Re: [chain] CatalogFactoryBase
Date Sun, 17 Oct 2004 17:23:11 GMT
Hashtable is indeed synchronized ... but it's *always* synchronized
even when you don't need it.  LogFactoryBase (which I'll bet you
glanced at :-) uses Hashtable because [logging] needed to be able to
work in a JDK 1.1 environment.  That's not an issue for [chain], since
we're already usng the JDK 1.2 collections classes, so I prefer to use
them throughout, so we have the opportunity to not synchronize in
cases where thread safety is not an issue -- it is here, though.

More subtly, though, you'll also note that I use Map instead of
HashMap to declare the actual instance variable, and the return values
from appropriate methods.  That way, the actual implementation class
could be specialized later without breaking method signatures.  That's
not as easy to do if you're throwing Hashtables around (any
specialized version would have to subclass Hashtable, and not some
more generic interface).

Craig


On Sun, 17 Oct 2004 11:48:24 -0400, sean.schofield@verizon.net
<sean.schofield@verizon.net> wrote:
> Craig,
> 
> Thanks for commiting those changes.  I noticed you had to make a few modifications. 
Sorry 'bout that - did my best.  One change you made I was curious about.  I was using a Hashtable
to store the classloaders and you changed it to Map with a synchronized block.  I was curious
as to why you feel this is better?  Isn't Hashtable already synchronized?
> 
> Just curious.
> 
> sean
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message