---
title: "有趣的懒汉式单例类"
author: "L.x"
date: "2012-03-07T10:13:56Z"
tags: ["lazy", "singleton", "单例类"]
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2012-03-07T10:13:56Z"
id: 1442482
url: "https://l-x.iteye.com/blog/1442482"
---

刚才在看代码时，看到了一个有趣的单例类懒加载模式，特贴出来供大家一起分享.

 

```
public class LazySingleton {
    private LazySingleton() {
    }

    public static LazySingleton getInstance() {
        return Holder.INSTANCE;
    }

    private static class Holder {
        public static final LazySingleton INSTANCE = new LazySingleton();
    }
}
```