单例模式示例
2015-12-23 09:48
344 查看
package pl.droidsonroids.gif; import java.util.concurrent.ScheduledThreadPoolExecutor; /** * Default executor for rendering tasks - {@link java.util.concurrent.ScheduledThreadPoolExecutor} * with 1 worker thread and {@link java.util.concurrent.ThreadPoolExecutor.DiscardPolicy}. */ final class GifRenderingExecutor extends ScheduledThreadPoolExecutor { private GifRenderingExecutor() { super(1, new DiscardPolicy()); } @SuppressWarnings("StaticNonFinalField") //double-checked singleton initialization private static volatile GifRenderingExecutor instance = null; public static GifRenderingExecutor getInstance() { if (instance == null) { synchronized (GifRenderingExecutor.class) { if (instance == null) { instance = new GifRenderingExecutor(); } } } return instance; } }
相关文章推荐
- Android编程开发之Spinner控件用法实例分析
- 串的模式匹配算法---RK
- 多线程编程与同步控制(Java与C)
- Qt之认识JSON
- spring security 转
- Android Native 实用型开发指南
- Javacript中文传参Java解码说明(附参考资料)
- CPU affinity
- nginx/apache/php隐藏http头部版本信息的实现方法
- 图算法
- jQuery判断checkbox是否选中的3种方法
- dos批处理:列出指定目录下所有文件
- vs错误【C1083 C1854 C4727】的若干解决办法
- 【详解】更新整个maven工程及相关底层并再运行的记录
- asp.net 母版页使用详解
- c# 组元(Tuple)
- 随想17:以我来看我村,以我村来看社会
- Pro*C基础
- multi-mechanize
- Fragment的深入浅出