On 22 December 2010 11:52, <simonetrip...@apache.org> wrote: > Author: simonetripodi > Date: Wed Dec 22 11:52:09 2010 > New Revision: 1051863 > > URL: http://svn.apache.org/viewvc?rev=1051863&view=rev > Log: > made fields volatile > removed synchronization on getters/setters methods > > Modified: > > commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java > > Modified: > commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java > URL: > http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java?rev=1051863&r1=1051862&r2=1051863&view=diff > ============================================================================== > --- > commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java > (original) > +++ > commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/StackKeyedObjectPoolFactory.java > Wed Dec 22 11:52:09 2010 > @@ -81,13 +81,13 @@ public class StackKeyedObjectPoolFactory > /** > * cap on the number of "sleeping" instances in the pool > */ > - private int maxSleeping; // @GuardedBy("this") > + private volatile int maxSleeping; // @GuardedBy("this")
The @GuardedBy comment needs to be removed, as it no longer applies. [Note: volatile is not always OK for int or long - e.g. if the field can be incremented, volatile is not sufficient. But here the writes don't depend on the previous value, so no possibility of an intervening thread.] > > /** > * initial size of the pool (this specifies the size of the container, > * it does not cause the pool to be pre-populated.) > */ > - private int initIdleCapacity; // @GuardedBy("this") > + private volatile int initIdleCapacity; // @GuardedBy("this") > > /** > * Returns the KeyedPoolableObjectFactory used by StackKeyedObjectPools > created by this factory > @@ -105,7 +105,7 @@ public class StackKeyedObjectPoolFactory > * @return maxSleeping setting for created pools > * @since 1.5.5 > */ > - public synchronized int getMaxSleeping() { > + public int getMaxSleeping() { > return this.maxSleeping; > } > > @@ -115,7 +115,7 @@ public class StackKeyedObjectPoolFactory > * @param maxSleeping > * @since 2.0 > */ > - public synchronized void setMaxSleeping(int maxSleeping) { > + public void setMaxSleeping(int maxSleeping) { > this.maxSleeping = maxSleeping; > } > > @@ -125,7 +125,7 @@ public class StackKeyedObjectPoolFactory > * @return initial capacity setting for created pools > * @since 1.5.5 > */ > - public synchronized int getInitialCapacity() { > + public int getInitialCapacity() { > return this.initIdleCapacity; > } > > @@ -135,7 +135,7 @@ public class StackKeyedObjectPoolFactory > * @param initIdleCapacity > * @since 2.0 > */ > - public synchronized void setInitIdleCapacity(int initIdleCapacity) { > + public void setInitIdleCapacity(int initIdleCapacity) { > this.initIdleCapacity = initIdleCapacity; > } > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org