Browse Source

生产连接的线程切换时,加个双检锁,确保线程状态准确

release/9.0
abel 6 years ago
parent
commit
9a756e4b3b
  1. 4
      fine-druid/src/com/fr/third/alibaba/druid/pool/DruidDataSource.java

4
fine-druid/src/com/fr/third/alibaba/druid/pool/DruidDataSource.java

@ -619,6 +619,8 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
}
private void checkThread() throws SQLException {
if (!createConnectionThread.isStarted() && !destroyConnectionThread.isStarted()) {
synchronized (this) {//线程安全问题,加个双检锁
if (!createConnectionThread.isStarted() && !destroyConnectionThread.isStarted()) {
createConnectionThread.setStarted(true);
createConnectionThread.start();
@ -631,6 +633,8 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
}
}
}
}
}
public void init() throws SQLException {
if (inited) {

Loading…
Cancel
Save