How does Thread.sleep() work when called from multiple threads

后端 未结 5 1948
暖寄归人
暖寄归人 2021-01-18 05:31

sleep() is a static method of class Thread. How does it work when called from multiple threads. and how does it figure out the current thread of execution. ?

or may

5条回答
  •  青春惊慌失措
    2021-01-18 05:47

    The sleep method sleeps the current thread so if you are calling it from multiple threads it will sleep each of those threads. Also there's the currentThread static method which allows you to get the current executing thread.

提交回复
热议问题