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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -