How to kill a thread immediately from another thread in java?
Posted
by
Sara
on Stack Overflow
See other posts from Stack Overflow
or by Sara
Published on 2010-12-25T16:12:52Z
Indexed on
2010/12/25
16:54 UTC
Read the original article
Hit count: 200
java
|multithreading
Hi, is there anyway to kill a thread or interrupt it immediately.
Like in one of my thread, i call a method which takes time to execute (2-4 seconds). This method is in a while(boolean flag) block, so i can interrupt it from the main thread.
But the problem is, if i interrupt it; it will wait till the executing loop is finished and then on next conditional check, it will stop execution.
I want it to stop right then. Is there anyway to do this?
© Stack Overflow or respective owner