Static method being called in a concurrent environment
I was wondering what would be the outcome (in terms of failure or success) what would happen in this scenario:
I have a class StrHelper
with static method +(NSString*) getFirstHalfOf:(NSString*)word
and 2 or more methods happen to simultaneously (due to being on different thre开发者_如何学运维ads) call the static method.
Does anyone have an idea of the outcome?
The exact outcome depend on what the method exactly does, but actually there should not be any problems since every thread has his own local variables, and this does not interfere with other threads' local variables.
If there are only local variables, and no modification of global variables (as seems from the method name), there should be no problem.
精彩评论