As I was trying to say, the reason to use the ConcurrentHashMap would be to
avoid unnecessary synchronization. Since the method is static many threads
might call it simultaneously, blocking eachother more than necessary.
Looking at the original code I guess the author (Pat?) was concerned about
performance or he would not have bothered with the double checked locking in
the first place.
I also believe the concurrent package is released as public domain so I
guess you could do whatever you want with it, for example just repackaging
the relevant 1-2 classes in webwork if you need them.
Anyway, I am not trying to convince you to do it this way. Do whatever you
see fit.

Cheers,

Dick Zetterberg
[EMAIL PROTECTED]

----- Original Message -----
From: "Jason Carreira" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 09, 2003 5:20 PM
Subject: RE: [OS-webwork] Bug catching contest...


> Right, but there's no need for an external lib, when you can just do:
>
> Collections.synchronizedMap(new HashMap())
>
> Jason
> -----Original Message-----
> From: Dick Zetterberg [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 09, 2003 7:30 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [OS-webwork] Bug catching contest...
>
> >
> > Actually this code wouldn't fix anything. The difference is that this
> code
> > is visibly not synchronized, while the previous code was unvisibly not
> > synchronized.
> >
> > The point is that to make it working, both get and put must be in the
> same
> > synchronized block. Otherwise you may just leave it unsynchronized. In
> > fact - this code would probably work well even not synchronized. It
> would
> > sometimes do unnecessary compilations.
> >
> > -- Mike
>
> I know that the code I posted could possibly do unnecessary
> compilations.
> However I thought that the reason for your complaints was that in the
> end a non-threadsafe HashMap was used in the original code. Having both
> get and put being done to it from many threads could possibly lead to
> more serious errors than just an unnecessary compilation, isn't that so?
>
> And for that reason I suggested the ConcurrentHashMap (rather than a
> Hashtable or similar) to avoid synchronization congestion.
>
> Cheers,
>
> Dick Zetterberg
> [EMAIL PROTECTED]
>
>




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to