Java threads: Is it possible view/pause/kill a particular thread from a different java program running on the same JVM?(Java 线程:是否可以从在同一 JVM 上运行的不同 Java 程序查看/暂停/杀死特定线程?)
问题描述
我有一个程序 'foo' 运行不同的线程,fooT1、fooT2、.. fooTn.
I have a program 'foo' running different threads, fooT1, fooT2, .. fooTn.
现在,如果我想编写另一个程序bar",它可能会杀死线程 fooTr,这可能吗?
Now if I want write another program 'bar', which could kill the thread fooTr, is that possible?
原因:线程 fooTr 跟踪产品许可证之一.如果这个线程被杀死;一个人可以无限期地运行这个产品.杀死 'foo' 本身是可以容忍的,因为这正是许可证到期时所做的事情.
Reason: One of the thread fooTr tracks product license. If this thread is killed; one may run this product indefinitely. And killing 'foo' itself is tolerable as 'foo' as that is exactly what is being done on license expiry.
系统:Linux 的 Fedora 发行版
System: Fedora Distribution of Linux
注意:启动 JVM 和程序 foo 的命令放在/etc/init.d 中,任何对 rc.1/rc.2/rc.3 结构有相当了解的人都可以更改/添加启动参数到这些.
Note: The commands which start JVM and program foo are placed in /etc/init.d and anyone who has a decent knowledge of rc.1/rc.2/rc.3 structure can change/add the starting parameters to these.
我希望我的问题很清楚.如果没有,我可以随时编辑它.
I hope my question is clear. If not, I can always edit it.
推荐答案
据我所知,直接这样做是不可能的.但是,您可以考虑在您的foo"上创建某种服务,可以从bar"调用该服务以终止线程.当然,有数百种方法可以实现这一点.我的第一个想法是使用 RMI.
To my knowledge it is not possible to do this directly. What you could consider however is to create some kind of service on your 'foo' that can be called from 'bar' to kill the thread. There are, of course, hundreds of ways to implement this. My first thought would be to do this using RMI.
这篇关于Java 线程:是否可以从在同一 JVM 上运行的不同 Java 程序查看/暂停/杀死特定线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java 线程:是否可以从在同一 JVM 上运行的不同 Java 程序查看/暂停/杀死特定线程?


- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01