首页 > 解决方案 > 在 Java 中处理挂起的线程

问题描述

如果线程挂在Java任务执行的某个地方,有人可以指导我如何处理线程吗?

假设我们有 10 个由父线程创建的线程,并且在这种情况下第一个子线程在其执行中挂起,我希望 9 个线程的其余部分正常执行它们的部分。那么,我们总共可以通过多少种不同的方式来实现这一目标?- 在 Java 中

PS-这是在一次采访中被问到的。

标签: javamultithreading

解决方案


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.


推荐阅读