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

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

How do you determine if a thread is running?

10条回答
  •  -上瘾入骨i
    2020-11-28 12:16

    Use Thread.currentThread().isAlive() to see if the thread is alive[output should be true] which means thread is still running the code inside the run() method or use Thread.currentThread.getState() method to get the exact state of the thread.

提交回复
热议问题