Commit f2938fbb authored by Tatyana's avatar Tatyana 👽

Monitor fixes #1

parent b1e56164
......@@ -10,7 +10,6 @@ import static java.nio.file.StandardWatchEventKinds.*;
public class FileMonitor extends Thread {
private FileSearcher fileSearcher;
private WatchService watcher = FileSystems.getDefault().newWatchService();
private boolean proceed = false;
private ArrayList<WatchKey> keys = new ArrayList<>();
private static FileMonitor instance;
......@@ -32,7 +31,6 @@ public class FileMonitor extends Thread {
}
public void registerDir(File newDir) {
proceed = true;
try {
Path dir = Paths.get(newDir.getAbsolutePath());
keys.add(dir.register(watcher,
......@@ -45,7 +43,6 @@ public class FileMonitor extends Thread {
}
public void stopMonitoring() {
proceed = false;
for (WatchKey key : keys) {
key.cancel();
}
......@@ -55,7 +52,7 @@ public class FileMonitor extends Thread {
public void run() {
fileSearcher = FileSearcher.getInstance();
while (proceed) {
while (keys.size() != 0) {
WatchKey key;
try {
key = watcher.take();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment