tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <>
Subject Re: DBCP is Single Threaded
Date Thu, 07 Nov 2013 16:03:55 GMT
On 07/11/2013 15:58, yogesh hingmire wrote:
> While looking to upgrade to tomcat7, i understand the connection pool is a
> major improvement. I read that
> commons-dbcp is single threaded, in order to be thread safe commons-dbcp
> locks the entire pool, even during query validation.

Where did you read that? While it might have been true of earlier DBCP
releases I'm fairly sure it is not true for current releases.

> So as i understand, the connection pool will be locked when handing out new
> connections and other threads which need connections from the pool will
> wait until they are handed their respective connection?

There are brief periods of locking but they do no last the entire of the
borrow() and the return() methods.

There is contention during borrow() and return() but you'll only notice
it on multi-core systems the borrow() / return() at high rates.

Tomcat 7 ships with jdbc-pool that does not have this contention.

DBCP2 also does not have this contention and is used (in snapshot form
as there has not yet been an official release) in Tomcat 8 onwards.

> Is my understanding right and if anyone could explain this better

The best way to understand exactly what is locked and when is to look at
the source.


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

View raw message