饿汉式,因为使用了静态修饰符在类加载时创建实例
private AsyncManager(){}
private static AsyncManager me = new AsyncManager();
public static AsyncManager me()
{
return me;
}
懒汉式,使用时才创建
public class AsyncManager {
private static AsyncManager me;
private AsyncManager() {}
public static synchronized AsyncManager me() {
if (me == null) {
me = new AsyncManager();
}
return me;
}
}