标准Singleton设计模式,多线程下

 public class SessionAssistant  {
  private static volatile SessionAssistant instance;
  private static object syncRoot = new Object();


  private SessionAssistant()
  {
  }

  public static SessionAssistant Instance
  {
   get
   {
    if ( instance == null )
    {
     lock ( syncRoot )
     {
      if ( instance == null )
      {
       instance = new SessionAssistant();
      }
     }
    }

    return instance;
   }
  }
 }

posted @ 2009-12-24 17:12  helloworld22  阅读(190)  评论(0编辑  收藏  举报