我想停止以下列方式生成的线程。线程用于查看文件夹中的文件。我尝试了很多,搜索了很多,但没有成功。
任何机构都可以提供帮助并建议任何解决方案来停止生成的线程,如下所示:
public class HelloRunnable implements Runnable {
public void run() {
WatchService for files in folders which starts and runs here
while (someCondition) {
create a thread for copying some file which exits when run() finishes
created in another class which implements Runnable class
}
}
public static void main(String args[]) {
for(int i = 0;i< 5; i ++)
new Thread(new HelloRunnable()).start();
}
}