Whether a method is thread safe or not depends on whether or not it accesses shared resources (e.x static variables,..). There is nothing to do with whether the method is static.
In your case, it's not sure to tell whether modifying sc
is thread safe or not. It depends on how this parameter is created and passed in to the method. In most of the cases, it's problematic if the passed in parameter is shared. When we develop a function, we should ensure that there is no problem no matter how the function is used.
With your lock
(I assume that _lock
is a static variable), you still don't achieve thread safe if sc
is shared and modified somewhere else on another thread.
With the method named modifySharedResource
(the parameter is shared), I'm quite sure there is a problem if the parameter is also modified somewhere else on another thread.
In general, it's a bad practice to modify incoming parameters: https://softwareengineering.stackexchange.com/questions/245767/is-it-an-antipattern-modifying-an-incoming-parameter