Unverified 提交 020e51db authored 作者: Andrei Tokar's avatar Andrei Tokar 提交者: GitHub

Merge pull request #1103 from turbanoff/master

Remove redundant synchronization
...@@ -35,7 +35,7 @@ public class Driver implements java.sql.Driver, JdbcDriverBackwardsCompat { ...@@ -35,7 +35,7 @@ public class Driver implements java.sql.Driver, JdbcDriverBackwardsCompat {
private static final ThreadLocal<Connection> DEFAULT_CONNECTION = private static final ThreadLocal<Connection> DEFAULT_CONNECTION =
new ThreadLocal<>(); new ThreadLocal<>();
private static volatile boolean registered; private static boolean registered;
static { static {
load(); load();
......
...@@ -33,9 +33,7 @@ class DatabaseCloser extends Thread { ...@@ -33,9 +33,7 @@ class DatabaseCloser extends Thread {
* database has been closed, or after a session has been created. * database has been closed, or after a session has been created.
*/ */
void reset() { void reset() {
synchronized (this) { databaseRef = null;
databaseRef = null;
}
} }
@Override @Override
...@@ -53,10 +51,9 @@ class DatabaseCloser extends Thread { ...@@ -53,10 +51,9 @@ class DatabaseCloser extends Thread {
} }
} }
Database database = null; Database database = null;
synchronized (this) { WeakReference<Database> ref = this.databaseRef;
if (databaseRef != null) { if (ref != null) {
database = databaseRef.get(); database = ref.get();
}
} }
if (database != null) { if (database != null) {
try { try {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论