开发者

Interrupt Thread

Can any body tell what is the purpose of using interrupt method开发者_如何转开发 of thread. Why we call interrupt method during execution??

Thanks


You call the interrupt method to interrupt the thread if it's in a blocking state... usually you interrupt a thread that's in a blocking state because it's either taking too long or your system is shutting down and you want to cancel whatever that thread is doing. Interrupt offers a "graceful" way to terminate a blocking thread, because it raises an interrupt exception and it's presumed that your thread is handing that exception. When your thread gets the interrupt exception, then it should gracefully terminate (i.e. clean up the state and exit any loops).

P.S. What programming language are you using?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜