org.zkoss.io
Class FileWatchdog
java.lang.Object
java.lang.Thread
org.zkoss.io.FileWatchdog
- All Implemented Interfaces:
- Runnable
public class FileWatchdog
- extends Thread
File modification monitor thread. It monitors a gving file in a lowest
priority thread. Then, if it detects any modification, invokes
a giving interface. Note: Callback.onModified is at least called once.
Caller has to implement the FileWatchdog.Callback interface. Then,
new FileWatchdog(filename, 30000, callback).start();
This class is extended from Thread, so you could manipulate it as
a normal thread, such as interrupt, suspend, and change priority.
The watchdog executes at the lowest priority, so it won't affect
much of the system performance.
- Author:
- tomyeh
|
Nested Class Summary |
static interface |
FileWatchdog.Callback
The interface to implement when using a FileWatchdog. |
|
Method Summary |
void |
cease()
Stops the thread. |
void |
run()
|
void |
start()
|
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
FileWatchdog
public FileWatchdog(File file,
long delay,
FileWatchdog.Callback callback)
- Constructor.
- Parameters:
file - the filedelay - the delay in milliseconds to wait between each checkcallback - the callback
FileWatchdog
public FileWatchdog(String filename,
long delay,
FileWatchdog.Callback callback)
- Constructor.
- Parameters:
filename - the filenamedelay - the delay in milliseconds to wait between each checkcallback - the callback
start
public void start()
- Overrides:
start in class Thread
cease
public void cease()
- Stops the thread.
run
public void run()
- Specified by:
run in interface Runnable- Overrides:
run in class Thread
Copyright © 2012. All Rights Reserved.