commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Verbeeck <>
Subject Re: [pool] faulty change of synchronization? - Re: cvs commit: jakarta-commons/pool/src/java/org/apache/commons/pool/impl
Date Wed, 13 Aug 2003 21:15:30 GMT
_numActive is an int so the synchronized block wasn't needed.
But the extra "synchronized" is in the case where a new object 
has to be created and not in the critical "get from pool" code path.

All the success code paths have now one synchronized block.
I'll leave it as is for now.


David Graham wrote:

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

View raw message