Say you want to share some resource, like a class or a variable across all threads/sessions within a ASP.NET web application. What is better?
1) A static variable having thread-safe accessors to that static variable?
2) Or a ASP.NET application session variable?
If you only have one of those, there is little difference.
If you have several, you should use static variables rather than
Applicationvariables. TheApplication.Lockmethod will lock allApplicationvariables, while you can use separate syncronisition identifiers for your static variables, so that each lock only affects the code that accesses that specific variable.