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
⌛
This post has been reserved for your question.
Hey @SidKid! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose 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.
💤
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.
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 notifiedwdym?
I responded to your question and I pinged you so that you get a notification
💤
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.