if Thread.sleep is static, how does individual thread knows it is put to sleep?

前端 未结 2 1837
走了就别回头了
走了就别回头了 2021-01-17 22:25

I am a bit confused with Thread.sleep() method. if Thread.sleep() is a static method, how does two threads know which is put to sleep. For example,

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 22:49

    It can find the current thread from Thread.currentThread(). The current thread only can put itself to sleep.

提交回复
热议问题