为什么一个线程会中断另一个线程 [英] Why a thread would interrupt another thread

查看:397
本文介绍了为什么一个线程会中断另一个线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java多线程应用程序中,我们处理InterruptedThreadException.如果另一个线程中断当前线程,则抛出此异常.现在,另一个线程在知道它将导致异常的情况下可能想要中断当前线程的原因是什么?

In Java multi threaded applications, we deal with InterruptedThreadException. This Exception is thrown if another thread interrupts the current thread. Now what is the reason another thread might want to interrupt the current thread when it knows that it is going to cause an Exception?

推荐答案

很多原因.但是最流行的一种方法是取消线程上的某些任务.

Many reasons. But the most popular one is to cancel some task on a thread.

请参见 http://www.ibm.com/developerworks /java/library/j-jtp05236/index.html 了解详情.

这篇关于为什么一个线程会中断另一个线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆