0

以下の方法で生成されたスレッドを停止したいと考えています。スレッドは、ファイルのフォルダーを監視するために使用されます。いろいろ試して、いろいろ調べましたが、うまくいきません。

次のように生成されたスレッドを停止するための解決策を提案してください。

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();
    }
}
4

2 に答える 2