Tuesday, March 13, 2012

Thread Safety?

i have an asp.net application which almost all of its methods are static methods.
is it prone for bugs and thread collisions or something?

No. There is nothing like that a static function is prone to bugs or collisions. Firstly, static member functions cannot access non-static members directly. A class member declared with the keywordstatic is a static member. A static member is owned by the class, not by its instances (objects of the class).
Note that static members are actually class members, while non-static members are instance members (means they are owned by the instances). Both in C# & VB.NET, we may create static/shared events, properties, fields and functions.

Due to the independent nature of static functions, it wont be affected by other threads at all.

HTH

Cheers

Vishal Khanna

(pls mark as answer if reply helps)

0 comments:

Post a Comment