rishabhdaim commented on PR #2457:
URL: https://github.com/apache/jackrabbit-oak/pull/2457#issuecomment-3204948747

   > * Thread 1 enters the synchronized block and executes up to `initialized = 
true`. It is suspended at this point
   > 
   > * Thread 2 enters the method and sees `initialized = true` because this 
variable is volatile. However, `result` is not volatile so we have no 
guarantees that it will be updated until thread 1 leaves the synchronized block.
   > 
   > * Thread 3 skips the initialization block and returns result, which is 
still null.
   
   @nfsantos This can't happen. Any thread which reads the updated value of 
`initialized = true` which only happens after updating `result`, it is bound to 
see all the changes of the thread updating `initialized` (which is thread 1 in 
this case) including the `result` variable.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: oak-dev-unsubscr...@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to