commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [POOL] Offer of help for a 1.4 release
Date Sun, 02 Dec 2007 21:24:03 GMT
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 
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?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message