饿汉式

饿汉式的代码很简单也不是我们的重点。

package singleton_k;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2020-01-15 20:41
 * @notify
 * @version 1.0
 */

public class Computer {

    private Computer() {
    }

    private static Computer computer = new Computer();

    public static Computer getInstance() {
        return computer;
    }
}
View Code

相关文章:

  • 2022-02-22
  • 2022-02-21
  • 2022-12-23
  • 2021-04-17
  • 2021-11-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
相关资源
相似解决方案