Java – how do I check if a thread is sleeping?

Is there any way to check whether a given thread is sleeping?

Solution

You can call thread Getstate() to check whether the state is timed_ WAITING.

But please note that timed_ Waiting does not necessarily mean that the thread is called sleep (), or it may be in object Wait (long) wait or similar call

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>