https://issues.apache.org/bugzilla/show_bug.cgi?id=49778

--- Comment #1 from Chuck Caldarale <chuck.caldar...@unisys.com> 2010-08-19 
08:54:53 EDT ---
(In reply to comment #0)
> Proposed solution:
> 
> public int getCount() {
>   int ret = 0;
>   synchronized (lock) {
>     ret = current+1;
>   }
>   return ret;
> }

Such a change is utterly useless.  Since the lock is dropped immediately after
retrieving the value, the value may change well before any decisions can be
made based on the value.  This is completely independent of the JVM memory
model.

If you want to insure that getCount always retrieves the current value, the
field must be flagged as volatile - but that does nothing to prevent it
changing the moment after it has been referenced.

 - Chuck

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to