开发者

Do dormant Threads made so by the readLock() or writeLock() methods in ReentrantReadWriteLock class consume CPU cycles?

I am using Java 6, and reading through Java Concurrency in Practice. I am trying to figure out if when using these methods, if a dormant thread waiting for the lock us开发者_StackOverflow社区es any CPU cycles while it is dormant. Anyone know? Thanks!

Matt


Any action consumes clock cycles. However when a thread is suspended, the number of clock cycles is fixed and does not depend on how long it is suspended for. This is good if the thread is suspended if even a relatively short period of times, but for a very short period of time its not very efficient which is why Lock doesn't suspend the thread immediately but retries a small number of times to get the lock before suspending the thread (in the hope it can avoid doing this)

I assume you are talking about Lock.lock() which ReentrantReadWriteLock.readLock() and ReentrantReadWriteLock.writeLock() support.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜