In Java, how do you determine if a thread is running?

后端 未结 10 2215
-上瘾入骨i
-上瘾入骨i 2020-11-28 11:30

How do you determine if a thread is running?

10条回答
  •  天命终不由人
    2020-11-28 12:12

    To be precise,

    Thread.isAlive() returns true if the thread has been started (may not yet be running) but has not yet completed its run method.

    Thread.getState() returns the exact state of the thread.

提交回复
热议问题