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