java - 在 Java 中处理挂起的线程
问题描述
如果线程挂在Java任务执行的某个地方,有人可以指导我如何处理线程吗?
假设我们有 10 个由父线程创建的线程,并且在这种情况下第一个子线程在其执行中挂起,我希望 9 个线程的其余部分正常执行它们的部分。那么,我们总共可以通过多少种不同的方式来实现这一目标?- 在 Java 中
PS-这是在一次采访中被问到的。
解决方案
Its better to analyse figure out why the thread is going on hung state and fix it. there must be some reason for going to hung state. Otherwise, you could check whether thread is getting completed within X milisec or not, If not getting completed, terminate it.
推荐阅读
- python - 格式化 SQL 查询以接受引用值列表
- javascript - 图像幻灯片不适用于以下代码
- vue.js - @vue/cli 4.5.13:热重载不起作用
- python - nidaqmx python在一定时间内计数脉冲
- javascript - “在控制器上未找到公共操作方法‘索引’”错误,即使我从未提及“索引”并提供了控制器的特定路径
- java - 读取 file.txt 并取其中的 int 值,然后将它们放入 2D 数组中用于数独
- c# - 带 DI 的 Newtonsoft 转换器
- async-await - Discord.py 错误语法错误:无效语法
- sql - 从多个表中删除列
- mysql - MySQL:对非唯一列的 FK