zoukankan      html  css  js  c++  java
  • 线程池

    常用创建线程池:

    Executors.newSingleThreadExecutor();
    Executors.newCachedThreadPool();
    Executors.newFixedThreadPool();
    Executors.newScheduledThreadPool();

    实践(使用上述内部实现):

    /**
    * 创建一个线程池用于处理
    */

    private
    static final ThreadPoolExecutor SINGLE_THREADPOOLEXECUTOR = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(100), new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setDaemon(true); return thread; } },new ThreadPoolExecutor.DiscardPolicy());

    使用:

    SINGLE_THREADPOOLEXECUTOR.execute(new Runnable() {
                @Override
                public void run() {
                    initExtendedAreaSurcharge();
                }
            });
  • 相关阅读:
    指数
    汉诺塔问题
    只用递归和当前的栈实现栈的逆序
    让你996的不是你的老板,而是其他愿意996的人
    luke towan
    2020-9-3
    2020-9-3
    springboot注解
    2020-9-2
    20200827
  • 原文地址:https://www.cnblogs.com/yifanSJ/p/12768209.html
Copyright © 2011-2022 走看看