How Thread.sleep() works internally

后端 未结 5 1427
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-15 00:49

Let\'s say I have a thread T and it is holding one resource R. If I call Thread.sleep() on the current thread i.e T, will it release the resource R (to let other threads use

5条回答
  •  鱼传尺愫
    2020-12-15 01:15

    The thread which is going to sleep will hold the lock(not release resource) while it sleeps. A sleeping thread will not even be scheduled for the time it sleeps (or until it is interrrupted and then it wakes up)

提交回复
热议问题