Java驻留线程 [英] Java parked thread

查看:1288
本文介绍了Java驻留线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java中的驻留线程和等待线程之间有什么区别?我有一个jboss核心转储,分析它显示了很多停滞的线程.

What is the difference between a parked thread and a waiting thread in java ? I've a jboss core dump and analysing it is showing a lot of parked threads.

推荐答案

查看

出于线程调度目的禁用当前线程,除非 许可证可用.如果许可证可用,则将其消耗掉 呼叫立即返回;否则,当前线程变为 出于线程调度目的而禁用,并且处于休眠状态,直到其中之一 发生三件事:

Disables the current thread for thread scheduling purposes unless the permit is available. If the permit is available then it is consumed and the call returns immediately; otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:

某些其他线程将当前线程作为unpark调用unpark 目标;或某些其他线程中断当前线程;或者 虚假调用(即无故)返回.此方法不 报告其中哪些导致方法返回.来电者应 重新检查导致线程在第一个停放的条件 地方.调用者还可以确定例如中断状态 返回时的线程数.

Some other thread invokes unpark with the current thread as the target; or Some other thread interrupts the current thread; or The call spuriously (that is, for no reason) returns. This method does not report which of these caused the method to return. Callers should re-check the conditions which caused the thread to park in the first place. Callers may also determine, for example, the interrupt status of the thread upon return.

因此,驻留线程是被LockSupport.park()阻塞的线程.

So a parked thread is a thread blocked using LockSupport.park().

这篇关于Java驻留线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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