locking the object inside a property, c# -
public arraylist inputbuffer { { lock (this.in_buffer) { return this.in_buffer; } } }
is this.in_buffer locked during call inputbuffer.clear?
or property lock in_buffer object while it's getting reference it; lock exits, , reference used clear?
in addition others have said scope of lock, remember aren't locking object, locking based on object instance named.
common practice have separate lock mutex jon skeet exemplifies.
if must guarantee synchronized execution while collection being cleared, expose method clears collection, have clients call that, , don't expose underlying implementation details. (which practice anyway - encapsulation.)
Comments
Post a Comment