摘要: lock:该关键字将语句块标记为临界区,方法是获取给定对象的互斥锁,执行语句,然后释放该锁。举例: 单件模式publicclassSingleton{privatestaticSingletoninstance=null;privatestaticreadonlyobjectsyncRoot=newobject();privateSingleton(){}publicstaticSingletonGetInstance(){if(instance==null){lock(syncRoot){if(instance==null){instance=newSingleton();}}}return 阅读全文
posted @ 2013-03-22 09:03 遥望星空 阅读(5324) 评论(0) 推荐(0) 编辑