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 23:02:13 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49778

--- Comment #2 from Sebb <sebb@apache.org> 2010-08-19 19:02:10 EDT ---
(In reply to comment #1)
> Such a change is utterly useless.  

Not true. 

The synchronisation block ensures that the value read by the thread is the
current value.

> 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.

True, but irrelevant here.

> If you want to insure that getCount always retrieves the current value, the
> field must be flagged as volatile 

Not strictly true.

Volatile is _one_ way to ensure safe publication, but it is not the _only_
solution.

Since the other accesses need to use synchronisation, it makes sense to use
synchronisation here too.

> - but that does nothing to prevent it
> changing the moment after it has been referenced.

Again true, but irrelevant.

-- 
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