thank you paul to point me at an omission.

> -----Original Message-----
> From: Paul Speed [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 29, 2001 11:54 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Thread-safety
> [...]
>       The problem is that the point of the code block is to be
> sure that the _jspx_init() method has been completed before 
> proceeding.  The problem is that _jspx_inited might appear to other
> threads to be set to true before the original thread has completed
> executing the _jspx_init() method (or at least before its changes
> are available to other threads).
> 
>       This means that the second thread would come through, see
> that _jspx_inited is true, and skip the synchronization block.  That
> threads execution would then proceed thinking that everything has
> been initialized when it hasn't.

ok, i see.  thank you again for clarifying.  do i now fully understand the
issue: the problem at hand cannot easily be solved by assigning the flag
from the return value of the init() method because of a combination of
inlining and reordering which might again lead to a prior assignment.  is
that so?

normally i would say that a code like "_jspx_inited = do_init();" may not be
rearranged in a way that the assignment occurs prior to finishing of the
method body (especially since there can be exceptions).  i would guess that
- by allowing this - a whole bunch of programs would run berserk or simply
break...  i cannot believe that people at sun would risk these consequences,
do they?

>       Check out the article that is referenced in other mail in
> this thread or hit JavaWorld and see the references section on the
> article about singletons.

this one?
http://www.javaworld.com/javaworld/jw-04-1999/jw-04-toolbox.html

regards

        robert

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to