Phil Steitz wrote:

- fully synchronized borrowObject() and returnObject() methods. I've
seen this to be a serious bottleneck when the database is under high
load and another connection needs to be created.

Agreed.  Ideas on how to improve this without creating threadsafety
issues would be appreciated.

I have started to implement a solution which has the basic idea to return a (Java 5) Future<Connection> instead of a Connection on borrowObject(). If we still have a pooled Connection I return an 'ImmediateFuture'. If a new connection is needed, I return a FutureTask which creates the new connection. The Task is executed by a SingleThreadExecutor with an unbounded queue. Thus the blocking on connection creation is moved to the caller thread and the pool is open for other threads. However I'm still not 100% convinced with this solution. E.g. I would like to immediate return a pooled connection to the waiting caller thread, if a connection is returned to the pool meanwhile.

Also, I understand that Java 5 is probably no option for commons-pool, as it must stay compatible with Java 1.4, right? But maybe you can take some of my ideas and implement a similar solution?

Christoph


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to