Hi Pete,
On Tue, Jul 20, 2004 at 11:21:44AM -0700, Pete Angstadt wrote:
> Has anyone considered creating a detector for improper
> use of synchronized classes?
>
> It's usually a performance problem when using
> Hashtable instead of HashMap, or Vector instead of
> ArrayList or an array.
>
> For example, an obvious problem is when a Hashtable or
> Vector is instantiated and used only locally within a
> method (and isn't passed as a parameter to another
> method). There are other possible problematic usages
> as well.
>
> Any thoughts on this?
It wouldn't be too hard to flag Hashtables and Vectors that
were created in a method, and not assigned to a field,
passed to another method, or returned from the creating method.
Those objects would not be visible to multiple threads,
and thus the synchronization would be unnecessary.
However, are you sure that those classes represent a significant
performance overhead? A lot of research (e.g., thin locks)
has been done to reduce the overhead of uncontended locks.
I would want to see performance results to know exactly what
the overhead is.
-Dave
|
|