c# - Static member and lock -
i have class static member:
static mayclass s_member;
it can accessed multiple threads. should use static lock object it?
if wish prevent concurrent access, need protect lock. if concurrent access presents no problems, there no need lock.
only knowledge of member can answer 1 way or another. threads access concurrently ever read? if so, not need lock. otherwise, if writing shared data, lock needed.
Comments
Post a Comment