On Monday, 6 May 2013 at 09:30:24 UTC, Sergei Nosov wrote:
On Monday, 6 May 2013 at 09:11:00 UTC, Mehrdad wrote:
On Monday, 6 May 2013 at 09:06:55 UTC, Mehrdad wrote:
lock (this)
{
_static = new ActualValue<T>();
}
Oops I forgot the null check inside, don't forget that.
All that double-checking stuff is trying to avoid calling
"lock" for entire Get function body. Your solution does exactly
that. So it's no good.
There are _two_ Get() functions. Only one of them calls lock();
once the field is initialized, that Get() is no longer called,
and the other one is called instead.
Unless I'm missing something?