start thread after watcher is added
This commit is contained in:
parent
4f4cb3643b
commit
134a80e9a3
@ -3,6 +3,7 @@ package net.hyperic.sigar.cmd;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import net.hyperic.sigar.Sigar;
|
import net.hyperic.sigar.Sigar;
|
||||||
@ -87,15 +88,14 @@ public class Watch {
|
|||||||
FileWatcherThread watcherThread =
|
FileWatcherThread watcherThread =
|
||||||
FileWatcherThread.getInstance();
|
FileWatcherThread.getInstance();
|
||||||
|
|
||||||
watcherThread.doStart();
|
|
||||||
|
|
||||||
watcherThread.setInterval(1000);
|
watcherThread.setInterval(1000);
|
||||||
|
|
||||||
FileWatcher watcher =
|
FileWatcher watcher =
|
||||||
new FileWatcher(sigar) {
|
new FileWatcher(sigar) {
|
||||||
public void onChange(FileInfo info) {
|
public void onChange(FileInfo info) {
|
||||||
System.out.println(info.getName() +
|
System.out.println(info.getName() +
|
||||||
" Changed:\n" + info.diff());
|
" Changed:\n" +
|
||||||
|
info.diff());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNotFound(FileInfo info) {
|
public void onNotFound(FileInfo info) {
|
||||||
@ -120,6 +120,8 @@ public class Watch {
|
|||||||
|
|
||||||
watcherThread.add(watcher);
|
watcherThread.add(watcher);
|
||||||
|
|
||||||
|
watcherThread.doStart();
|
||||||
|
|
||||||
System.out.println("Press any key to stop");
|
System.out.println("Press any key to stop");
|
||||||
try {
|
try {
|
||||||
System.in.read();
|
System.in.read();
|
||||||
|
Loading…
Reference in New Issue
Block a user