On 4 February 2015 at 13:51, Phil Steitz <[email protected]> wrote:
> I had to go around getNumIdle to avoid waiting on a this lock in the
> unit test I just committed.  With pool 2 and volatile connectionPool
> instance, I don't think this sync is needed any more.  Same with the
> sync on getNumActive.  Am I missing something here?

I think there are two potential issues here.

The first is that getNumIdle will fail with NPE if another thread
closes the pool in the meantime.
That can be handled by taking a copy of the reference first.

The second possible issue is ensuring safe publication - I think
volatile should be sufficient here.

> Phil
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to