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

后端 未结 4 667
日久生厌
日久生厌 2021-01-17 03:14

I would like to stop threads generated in the following manner by using jToggleButton. The threads are used for watching folders for files. I tried a lot, and searched alot,

4条回答
  •  情书的邮戳
    2021-01-17 03:54

    There is a Thread.stop() method, but is has been deprecated, because it's unsafe.

    Instead of using the deprecated method(s), you can modify some variable to indicate that the target thread should stop running.

提交回复
热议问题