haitao:
java的synchronized(classx) { code; }不是让整个code不受打断的执行?
[阅读: 473] 2008-07-04 08:01:05
public static LazySingleton getInstance()
{
if (m_instance == null)
{
//More than one threads might be here!!!
那如果改为在这里检测某个信号量呢?
synchronized(LazySingleton.class)
{
if (m_instance == null)
{
m_instance = new LazySingleton();
}
}
}
return m_instance;
}