示例如下
package com.example.demo.service;
/**
* 实现一个附带的 单例方法(懒汉模式)
*
* @description: TestService
* @author: leimin
* @date: 2021/5/24 13:50
*/
public class TestService {
public static TestService getInstance() {
return Singleton.engine;
}
private static class Singleton {
private static TestService engine = new TestService();
}
// todo 其他业务代码;
}