I am trying to implement postponed initialization (object is not initialize
till requested).
public class clsStore
{
volatile List<clsPicture Group_lstPictur eGroups = null;
public List<clsPicture GroupPictureGro ups
{
get
{
if (_lstPictureGro ups == null)
{
lock (this)
{
if (_lstPictureGro ups == null)
_lstPictureGrou ps = LoadPictureGrou p();
}
}
return _lstPictureGrou ps;
}
}
}
Obviously this code suppose to run in multithreaded enviroment in ASP.NET.
Anyone sees any problem in this code?
As far as i can see there is no 'race' condition here and code is safe.
Thanks
George.
till requested).
public class clsStore
{
volatile List<clsPicture Group_lstPictur eGroups = null;
public List<clsPicture GroupPictureGro ups
{
get
{
if (_lstPictureGro ups == null)
{
lock (this)
{
if (_lstPictureGro ups == null)
_lstPictureGrou ps = LoadPictureGrou p();
}
}
return _lstPictureGrou ps;
}
}
}
Obviously this code suppose to run in multithreaded enviroment in ASP.NET.
Anyone sees any problem in this code?
As far as i can see there is no 'race' condition here and code is safe.
Thanks
George.
Comment