commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Graham <grahamdavid1...@yahoo.com>
Subject Re: [pool] faulty change of synchronization? - Re: cvs commit: jakarta-commons/pool/src/java/org/apache/commons/pool/impl GenericObjectPool.java
Date Wed, 13 Aug 2003 19:32:10 GMT
--- Dirk Verbeeck <dirk.verbeeck@pandora.be> wrote:
> The pool manipulation was synchronized, only the isEmpty() test is not.
> I didn't realize that _numActive++ should be synchronized, I thought the
> 
> ++ operator was atomic.

The datatype the operator is applied to is what matters.  Assignments to
ints are atomic, assignments to longs aren't because they are 64 bits. 
So, if _numActive is an int, I don't think it needs to be synchronized.

David

> I'll put these also in a synchronized block.
> 
>
http://cvs.apache.org/viewcvs/jakarta-commons/pool/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=1.23&content-type=text/vnd.viewcvs-markup
> 
> How does this new version looks?
> 
> Dirk
> 
> John McNally wrote:
> 
> >My quick read of this change is not favorable.  It looks like changes
> to
> >an unsynchronized list have been moved outside any synchronization. 
> >Also integer math like numActive++ outside a synchronization block has
> >got me into problems in the past.  A test with two threads using i++
> and
> >i-- ran quite some time (couple hours) on a single processor box, but
> >did eventually fail.  Then the test was run on a dual processor box, it
> >failed pretty much immediately, repeatedly.
> >
> >I'm -1 on this change.
> >
> >john mcnally
> >  
> >
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Mime
View raw message