Critical Section?

  • Thread starter Thread starter Ed S
  • Start date Start date
E

Ed S

HiAll,

What would you suggest I use if I want to protect the creation of a
singleton - in the instance() static method. In C++, I'd use a critical
section.

Thanks,

--Ed
 
say
lock(this)
{
create singleton here
}

Locking on this is bad though because some other thread could conceivably
lock on this creating a deadlock of sorts. But that will give you roughly
the equivalent of a critical section.
 
Back
Top