tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49778] Inconsistent synchronization in SimplePool.java
Date Thu, 19 Aug 2010 12:54:58 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49778

--- Comment #1 from Chuck Caldarale <chuck.caldarale@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message