id executor impl. for demo purposes Executor executor = new Executor() { public void execute(Runnable command) { command.run(); } }; executor.execute(tailer);
2.3 Using a Thread
TailerListener listener = new MyTailerListener(); Tailer tailer = new Tailer(file, listener, delay); Thread thread = new Thread(tailer); thread.setDaemon(true); // optional thread.start();
3. Stopping a Tailer
Remember to stop the tailer when you have done with it:
tailer.stop();
4. Interrupting a Tailer
You can interrupt the thread a tailer is running on by calling {@link Thread#interrupt()}.
thread.interrupt();
If you interrupt a tailer, the tailer listener is called with the {@link InterruptedException}.
The file is read using the default charset; this can be overriden if necessary
@see TailerListener
@see TailerListenerAdapter
@version $Id: Tailer.java 1586350 2014-04-10 15:57:20Z ggregory $
@since 2.0
@since 2.5 Updated behavior and documentation for {@link Thread#interrupt()}