On Wednesday, 30 May 2012 at 12:43:15 UTC, deadalnix wrote:
It doesn't address most of the drawback cited. Notably the fact
that every object have a monitor field, but most of them will
not use it.
That could be solved without abandoning object locks. If locking
on all objects is allowed, objects in TLS could simply omit the
monitor field. Locking would then be performed as:
if (object not in TLS) {
insert expensive locking operation here
}
return
Yes, this would introduce an extra conditional jump whenever a
lock is acquired/released, but the overhead is very small
compared to the relatively expensive lock/unlock operation.