I like Michal's suggestion of ditching the syncs entirely -- this is
classic example of premature optimization AND bad assumptions :) 

Guilty as charged...

-Pat


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Michal Mosiewicz
Sent: Thursday, October 09, 2003 4:44 AM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] Bug catching contest...


----- Original Message -----
From: "Dick Zetterberg" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 09, 2003 10:07 AM
Subject: Re: [OS-webwork] Bug catching contest...


>
> Can't you just fix this by using a ConcurrentHashMap or a
ConcurrentReaderHashMap from the EDU.oswego.cs.dl.util.concurrent
package
for the expressions?
> So the code would be something like:
>
>    public static Object compile(String expression) throws
OgnlException {
>          Object o = null;
>
>          o = expressions.get(expression);
>
>          if (o == null) {
>                      o = Ognl.parseExpression(expression);
>                      expressions.put(expression, o);
>          }
>
>          return o;
>      }

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



-------------------------------------------------------
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


-------------------------------------------------------
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