how does one kill threads in Java? (I am unable to find something that works for Java 23)

all the ones I can find are deprecated
5 Replies
JavaBot
JavaBot3w ago
This post has been reserved for your question.
Hey @SidKid! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
dan1st
dan1st3w ago
You shouldn't kill threads. All ways to do that are deprecated because you shouldn't do it. You should use interruption instead. So instead of killing a thread, you should interrupt it via Thread#interrupt which is equivalent to asking it to stop - if the thread is waiting via some mechanism that supports interruption, it stops waiting and throws an InterruptedException (which you should never ignore - if you continue, you should at least call Thread.currentThread.interrupt() again to re-interrupt it). Otherwise, you can check for interruption using Thread.currentThread().isInterrupted ping to get you notified
SidKid
SidKidOP3w ago
wdym?
dan1st
dan1st3w ago
I responded to your question and I pinged you so that you get a notification
JavaBot
JavaBot3w ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?