use ReentrantLock replace sysnchronized. for ali jvm fiber wisp

This commit is contained in:
wenshao
2017-03-14 10:07:05 +08:00
parent 781f4de2b4
commit aa8459e192
6 changed files with 124 additions and 59 deletions
@@ -231,6 +231,8 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
protected Condition notEmpty;
protected Condition empty;
protected ReentrantLock activeConnectionLock = new ReentrantLock();
protected AtomicLong createCount = new AtomicLong();
protected AtomicLong destroyCount = new AtomicLong();
@@ -1372,8 +1374,11 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
}
public Set<DruidPooledConnection> getActiveConnections() {
synchronized (activeConnections) {
activeConnectionLock.lock();
try {
return new HashSet<DruidPooledConnection>(this.activeConnections.keySet());
} finally {
activeConnectionLock.unlock();
}
}