从操作系统中杀死一个java线程
我们运行由 SAP 构建的应用程序,该应用程序在 IBM JRE 上运行。 我可以使用 ps -mpkill
命令中可能有一些信号?
我听说java调试器可以用来随机杀死线程。有人可以指导我在哪里可以最好地学习其用法吗?
We run application built by SAP which runs on IBM JRE.
I can get the thread level CPU usage using ps -mp <PID> -o THREAD
. Is there any similar way to kill a particular thread from OS (AIX 5.3)? May be some signal in kill
command?
I have heard that java debugger can may be used to kill threads randomly. Can someone guide me where I can learn its usage best?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
即使您在技术上可以做到这一点,我也不建议这样做,因为包含线程的程序可能不准备处理这种情况,然后创建随机错误。
想象一下这样的场景:相关线程持有锁,以便其他线程等待该锁。现在,当您从外部终止线程时,它不会释放锁,您的应用程序将永远等待锁的释放。
Even if you technically can do it, I would not recommend to do it, as the program, that includes the thread may not be prepared to handle this situation and then create random errors.
Just imagine the scenario where the thread in question holds a lock, so that other threads wait on the lock. Now when you kill the thread from outside, it will not release the lock and your app will just wait forever on release of the lock.