zoukankan      html  css  js  c++  java
  • 多线程笔记


    在创建线程池的时候不管你创建的是newFixedThreadPool,还是newCachedThreadPool,还是newSingleThreadPool
    在里面调用的都是new ThreadPoolExecutor这个类,知识传入的参数值不同而已
    实例:
    public static ExecutorService newCachedThreadPool() {
    return new ThreadPoolExecutor(0, Integer.MAX_VALUE,
    60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
    }

    默认情况下,线程池中并没有任何线程,而是等待有任务到来才创建线程去执行任务

    public class ThreadPoolExecutor extends AbstractExecutorService {

        .....
        public ThreadPoolExecutor(int corePoolSize,int maximumPoolSize,long keepAliveTime,TimeUnit unit,
                BlockingQueue<Runnable> workQueue);
     
        public ThreadPoolExecutor(int corePoolSize,int maximumPoolSize,long keepAliveTime,TimeUnit unit,
                BlockingQueue<Runnable> workQueue,ThreadFactory threadFactory);
     
        public ThreadPoolExecutor(int corePoolSize,int maximumPoolSize,long keepAliveTime,TimeUnit unit,
                BlockingQueue<Runnable> workQueue,RejectedExecutionHandler handler);
     
        public ThreadPoolExecutor(int corePoolSize,int maximumPoolSize,long keepAliveTime,TimeUnit unit,
            BlockingQueue<Runnable> workQueue,ThreadFactory threadFactory,RejectedExecutionHandler handler);
        ...
    }
     
     
  • 相关阅读:
    R语言 which() 、 which.min() 、 which.max() 函数
    R rep() 函数
    R语言 一个向量的值分派给另一个向量
    R语言 sample抽样函数
    超参数 hyperparameters
    随机游走模型(Random Walk)
    随机数
    Lambda 函数与表达式
    static
    变量的申明定义
  • 原文地址:https://www.cnblogs.com/handsome1013/p/9995081.html
Copyright © 2011-2022 走看看