I have a class in my asp mvc app which keeps some "global" data. it is implemented as singleton. It looks something like this:
class InfoStrings
{
public List<string> strings = new List<string>();
static InfoStrings me = null;
private InfoStrings()
{ }
public static InfoStrings GetMe()
{
if(me == null)
me = new InfoStrings();
return me;
}
}
Now from controller's code I access this class by locking on it like this:
lock (InfoStrings.GetMe())
{
...
}
Ok, 2 questions:
1)Theoretically, can my InfoStrings
object be garbage collected?
2)Am I doing proper locking there?