对设计方式—Singleton模式的认识

对设计模式—Singleton模式的认识
在过去取老婆可以三妻六妾,不过现在有了法律规定一人只能一妻。
public class Wife
{
    private static  Wife wife = new Wife();

    public static Wife getWife()
    {
       return wife;
    }
    private Wife()
    {
     
    }
}

public class Wife
{
    private static  Wife wife ;

    public static synchronized Wife getWife() 
    {

       if (wife == null)
       wife = new Wife();
         return wife;   
     } 
    private Wife()
    {
  
    }
1 楼 okhaoba 2008-04-10  
private Wife() {}