public sealed class Singleton<T> where T:new()
    
{
        
private static T instance = new T();
        
private static object lockHelper = new object();
        
private Singleton() { }
        
public static T GetInstance()
        
{
            
if (instance == null)
            
{
                
lock (lockHelper)
                
{
                    
if (instance == null)
                    
{
                        instance 
= new T();
                    }

                }

            }

            
return instance;
        }

    }
 
posted on 2008-01-23 15:35  wkjs  阅读(132)  评论(0编辑  收藏  举报