zoukankan      html  css  js  c++  java
  • 单例模式示例

    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;
        }
    }
  • 相关阅读:
    几种网络LeNet、VGG Net、ResNet原理及PyTorch实现
    学习Faster R-CNN代码faster_rcnn(八)
    应用安全
    应用安全
    应用安全
    应用安全
    应用安全
    渗透测试
    应用安全
    应用安全
  • 原文地址:https://www.cnblogs.com/bigben0123/p/5068954.html
Copyright © 2011-2022 走看看