Is there a way to kill a child thread after some specified time limit in Java?
Edit: Also this particular thread may be blocked in its worst case (Thread is used to wait for a file modification and blocks until this event occurs), so im not sure that interrupt() will be successful?
Is there a way to kill a child thread after some specified time limit
Share
Make use of
ExecutorServiceto execute theCallable, checkout the methods wherein you can specify the timeout. E.g.Here
Taskof course implementsCallable.