如何使用VisualVM或unix命令杀死Java线程? [英] How to kill a java thread using VisualVM or using a unix command?

查看:177
本文介绍了如何使用VisualVM或unix命令杀死Java线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows 7 OS.我的应用程序中有大约6个线程.为了测试警报以检查线程的运行状况,我需要手动杀死线程并检查警报是否正常运行.我们可以像杀死它的pid那样杀死一个线程吗?

I m using windows 7 OS. I have around 6 threads in my application. For the purpose of testing the alerts to check the health of the threads, i need to kill the threads manually and check if the alerts are working properly. Can we kill a thread like how we kill a process with its pid?

推荐答案

没有一种不杀死进程的安全方法来杀死"线程.这不是您要刻意做的事情.为了进行测试,我会向您的应用程序添加代码以支持此操作.

There is no safe way to "kill" a thread without killing the process it is in. It not something you would do deliberately. For testing purposes I would add code to your application to support this.

这篇关于如何使用VisualVM或unix命令杀死Java线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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