gpt4 book ai didi

Java停放线程

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:55:08 25 4
gpt4 key购买 nike

Java 中的停放线程和等待线程有什么区别?我有一个 jboss 核心转储,分析它显示有很多停放的线程。

最佳答案

Javadoc park() 方法:

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:

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() 阻塞的线程。

关于Java停放线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10009347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com