The root of the problem is that you are out of connections. If you know you will need at max N connections for your application, give the pool a size of N+1 and Thread A will never have to wait for a connection. Finding out N is the task you have to perform and also ensure that N isn't higher than what your hardware can handle. You could simply over-provision and set a very high value, but be sure to monitor the pool usage and reduce the value if you can. |