Tuesday, 10 September 2013

How to stop threads of following type in Java used for watching folders for files using WatchService for folders

How to stop threads of following type in Java used for watching folders
for files using WatchService for folders

I would like to stop threads generated in the following manner. The
threads are used for watching folders for files. I tried a lot, and
searched alot, but am not successful. Could any body help and suggest any
solution to stop threads generated like:
public class HelloRunnable implements Runnable {
public void run() {
//-----------------------------------------------
WatchService for files in folders which starts and runs here
//-----------------------------------------------
}
public static void main(String args[]) {
for(int i = 0;i< 5; i ++)
new Thread(new HelloRunnable()).start();
}
}

No comments:

Post a Comment