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

Closing the file lock will now wait until the background thread is stopped.

上级 f730a281
...@@ -79,6 +79,11 @@ public class FileLock implements Runnable { ...@@ -79,6 +79,11 @@ public class FileLock implements Runnable {
*/ */
private volatile ServerSocket serverSocket; private volatile ServerSocket serverSocket;
/**
* Whether the file is locked.
*/
private volatile boolean locked;
/** /**
* The number of milliseconds to sleep after checking a file. * The number of milliseconds to sleep after checking a file.
*/ */
...@@ -96,7 +101,6 @@ public class FileLock implements Runnable { ...@@ -96,7 +101,6 @@ public class FileLock implements Runnable {
private String method, ipAddress; private String method, ipAddress;
private Properties properties; private Properties properties;
private boolean locked;
private String uniqueId; private String uniqueId;
private Thread watchdog; private Thread watchdog;
...@@ -152,6 +156,7 @@ public class FileLock implements Runnable { ...@@ -152,6 +156,7 @@ public class FileLock implements Runnable {
try { try {
if (watchdog != null) { if (watchdog != null) {
watchdog.interrupt(); watchdog.interrupt();
watchdog.join();
} }
} catch (Exception e) { } catch (Exception e) {
trace.debug(e, "unlock"); trace.debug(e, "unlock");
...@@ -484,7 +489,7 @@ public class FileLock implements Runnable { ...@@ -484,7 +489,7 @@ public class FileLock implements Runnable {
@Override @Override
public void run() { public void run() {
try { try {
while (fileName != null) { while (locked && fileName != null) {
// trace.debug("watchdog check"); // trace.debug("watchdog check");
try { try {
if (!FileUtils.exists(fileName) || FileUtils.lastModified(fileName) != lastWrite) { if (!FileUtils.exists(fileName) || FileUtils.lastModified(fileName) != lastWrite) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论