架构杂谈

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2014年3月20日

摘要: public class Singleton { private static volatile Singleton singleton = null;//volatile阻止JVM对指令执行顺序的优化,防止乱序执行导致导致返回的实例为半成品 private void Singleton() {} public static Singleton getInstance() { if (singleton == null) { synchronized (Singleton.class) { if (singleton == null) {//双重检查,如果第二个线程进入不做检查会产... 阅读全文
posted @ 2014-03-20 17:04 架构杂谈 阅读(170) 评论(0) 推荐(0) 编辑

2014年2月9日

摘要: public class Test4 { public static void main(String[] args) { int i = 0; i = i++ + i++ + i++ + ++i; }}结果为7,下面是javap dump出来的JVM指令集,后面附上执行说明, 0: iconst_0 //把0压入操作栈顶 1: istore_1 //i = 0; 2: iload_1 //把i的值压入栈顶 3: iinc 1, 1 //i=1 此时局部变量i值等于1 6: istore_2 ... 阅读全文
posted @ 2014-02-09 22:18 架构杂谈 阅读(571) 评论(3) 推荐(0) 编辑

2013年11月20日

摘要: 阅读全文
posted @ 2013-11-20 21:10 架构杂谈 阅读(215) 评论(0) 推荐(0) 编辑

摘要: 阅读全文
posted @ 2013-11-20 21:08 架构杂谈 阅读(146) 评论(0) 推荐(0) 编辑

2013年9月1日

摘要: grantselect, insert, update, deleteon testdb.*to common_user@'%' 阅读全文
posted @ 2013-09-01 12:24 架构杂谈 阅读(209) 评论(0) 推荐(0) 编辑