提交 a7c1080b authored 作者: Thomas Mueller's avatar Thomas Mueller

After closing a database, the writer thread will stop almost immediately…

After closing a database, the writer thread will stop almost immediately (instead of after at most 100 ms). This should avoid error messages in the Tomcat log file after a shutdown.
上级 92169c95
......@@ -95,16 +95,18 @@ public class WriterThread implements Runnable {
// wait 0 mean wait forever, which is not what we want
wait = Math.max(wait, Constants.MIN_WRITE_DELAY);
do {
// wait 100 ms at a time
int w = Math.min(wait, 100);
try {
Thread.sleep(w);
} catch (InterruptedException e) {
// ignore
synchronized (this) {
while (!stop && wait > 0) {
// wait 100 ms at a time
int w = Math.min(wait, 100);
try {
wait(w);
} catch (InterruptedException e) {
// ignore
}
wait -= w;
}
wait -= w;
} while (wait > 0 && !stop);
}
}
databaseRef = null;
}
......@@ -114,6 +116,11 @@ public class WriterThread implements Runnable {
*/
public void stopThread() {
stop = true;
synchronized (this) {
notify();
}
// can't do thread.join(), because this thread might be holding
// a lock that the writer thread is waiting for
}
/**
......@@ -122,7 +129,7 @@ public class WriterThread implements Runnable {
*/
public void startThread() {
thread.start();
this.thread = null;
thread = null;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论