提交 c50ac069 authored 作者: Andrey Turbanov's avatar Andrey Turbanov

Remove redundant synchronization

上级 a715afa5
...@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论