G
Guest
Hello,
It might seem like a stupid question to some. But I need to put this issue
to rest once and for all, since it keeps coming up in code reviews every now
and then.
There’s a static function in business logic class invoked by a Web
multi-user application. Each request calls this static function passing in
one unique ID, and XML serialized object (as out param), function
deserializes XML to object, creates new instances of DB Access object and
makes calls to database based on ID, modifies object’s properties and
serializes it back to be returned as out param.
Now there are concerns coming from some developers that it’s not
thread-safe, that static function might cause race-conditions, if
simultaneous calls are made to the static function there will be "detrimental
consequences".
Are the any real thread safety/race conditions issues with static functions?
Can someone tell me or point to a good link “behind the scenes†how static
function get invoked:
1. Will each call get its own stack?
2. How simultaneous calls are processed?
It might seem like a stupid question to some. But I need to put this issue
to rest once and for all, since it keeps coming up in code reviews every now
and then.
There’s a static function in business logic class invoked by a Web
multi-user application. Each request calls this static function passing in
one unique ID, and XML serialized object (as out param), function
deserializes XML to object, creates new instances of DB Access object and
makes calls to database based on ID, modifies object’s properties and
serializes it back to be returned as out param.
Now there are concerns coming from some developers that it’s not
thread-safe, that static function might cause race-conditions, if
simultaneous calls are made to the static function there will be "detrimental
consequences".
Are the any real thread safety/race conditions issues with static functions?
Can someone tell me or point to a good link “behind the scenes†how static
function get invoked:
1. Will each call get its own stack?
2. How simultaneous calls are processed?