没有合适的资源?快使用搜索试试~ 我知道了~
提高java性能.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 62 浏览量
2021-10-04
18:50:08
上传
评论
收藏 84KB PDF 举报
温馨提示
试读
15页
提高java性能.pdf
资源推荐
资源详情
资源评论
java
1.
1
public class Singleton {
private Singleton() {}
private static Singleton single=null;
// getInstance
public static Singleton getInstance() {
//
if (single == null) {
single = new Singleton();
}
return single;
}
}
Singleton private
Singleton
getInstance()
Singleton
1 getInstance
[java] view plain copy print?
1. public static synchronized Singleton getInstance() {
2. //
3. if (single == null) {
4. single = new Singleton();
5. }
6. return single;
7. }
2
[java] view plain copy print?
1. public static Singleton getInstance() {
2. if (singleton == null) {
3. synchronized (Singleton.class) {
4. if (singleton == null) {
5. singleton = new Singleton();
6. }
7. }
8. }
9. return singleton;
10. }
3
[java] view plain copy print?
1. public class Singleton {
2. private static class LazyHolder {
3. private static final Singleton INSTANCE = new Singleton();
4. }
5. private Singleton (){}
6. public static final Singleton getInstance() {
7. return LazyHolder.INSTANCE;
8. }
9. }
1 2
2
public class Singleton1 {
private Singleton1() {}
private static final Singleton1 single = new Singleton1();
//
public static Singleton1 getInstance() {
return single;
}
}
2.
stataic gc
Java
1. public class A{
2. static B b = new B();
3. }
b A A b
剩余14页未读,继续阅读
资源评论
maodi_lzc
- 粉丝: 1
- 资源: 3万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功