Mircea Markus wrote:
Hi,
this method obtains the lock requestor associated with the current
thread, which ultimately performs an ThreadLocal.get(key).
Can't we pass the lock owner to the lock before acquiring locks to avoid
this lookup map lookup? This would mean some code changes, but I think
we'll gain some performance.
You mean like setting a field? This would be a race condition. This
really should be a parameter, but that would require reimplementing AQS,
and not adhering to the lock interface. Ultimately though, i think the
map lookup pales in comparison to the lock operation :)