Java Apache CVS Development wrote:
> User: rafal
> Date: 01/02/01 13:21:54
>
> Modified: src/java/org/apache/turbine/services BaseInitableBroker.java
> BaseServiceBroker.java
> Log:
> Today I discovered that concurrent execution of init() methods was giving a hard
> time to my application. I introduced double checked locking around the calls
> to init(). I know that there are issues with this pattern, but I don't understand
> them good enought to determine if it can be harmful in this particular context.
>
> Even if we request the init() methods to be synchronized, there still will be
> a possiblity that init() will be called multiple times.
OK, the above can be easily solved by forcing the following pattern on
all services
public class SomeServiceImpl extends TurbineBaseService implements
SomeService
{
//....
public void synchronized init()
{
if(getInit())
{
return;
}
// do usefull stuff here
setInit(true);
}
}
Still, introducing double checked locking into the Broker code would
lift the
burden from Service authors.
Rafal
--
Rafal Krzewski
Senior Internet Developer
mailto:[EMAIL PROTECTED]
+48 22 8534830 http://e-point.pl
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]