@Jeff is correct.
... and someone will be erroneously destroyed.
The threads are not "killed" or "destroyed." They cease as a result of actions that they take themselves. Two flow completion scenarios:
The run() method is returned. This usually happens by design; those. because the method completed everything that it was intended to be executed.
The run() method throws or throws an exception. This usually happens due to some error in the thread that throws an unexpected exception.
(I ignore the possibility that some JVMs may implement the deprecated Thread.destroy() method, and someone might be so crazy as to call it.)
This does not mean that stopping the monitoring flow is not a useful task. Just the reason for the termination of the flow is different from what you put forward in your question / comments.
source share