The documentation of PoolableObjectFactory states:
PoolableObjectFactory must be thread-safe.
Looking at your code, the only thing that could be thread unsafe is the call to obj.release();
. This is possibly where your problem is.
Apart from that all looks ok...