1 Jul 2009 02:18
Re: adaptive spinning/biased lockingand java.util.concurrent.lock
David Holmes <davidcholmes <at> aapt.net.au>
2009-07-01 00:18:25 GMT
2009-07-01 00:18:25 GMT
Can I also clarify something about biased-locking as I recently encountered some very mis-guided perceptions of what it is. :) Biased-locking exists to make un-needed synchronization as cheap as possible. It works on the assumption that objects are not shared, so locks are not contended and so aren't in fact needed. So when an object acquires a monitor lock it simply does a fast-lock by CAS'ing in the owning thread's Id into the object header. But the release of the lock is almost a no-op, it leaves the object "locked" by that original thread. Subsequent locks by that thread then don't need the (expensive) CAS. If another thread tries to lock the object we go through an expensive bias-revocation process and revert to using normal locking - the fact that contention occurred shows biasedlocking is not applicable to this object. As Doug says you don't tend to use j.u.c Locks in circumstances where biased-locking would be beneficial. Cheers, David Holmes > -----Original Message----- > From: concurrency-interest-bounces <at> cs.oswego.edu > [mailto:concurrency-interest-bounces <at> cs.oswego.edu]On Behalf Of Doug Lea > Sent: Wednesday, 1 July 2009 6:52 AM > To: Peter Veentjer > Cc: concurrency-interest <at> cs.oswego.edu > Subject: Re: [concurrency-interest] adaptive spinning/biased lockingand > java.util.concurrent.lock > >(Continue reading)
RSS Feed