美文网首页
面试备忘

面试备忘

作者: itcode | 来源:发表于2019-07-07 19:09 被阅读0次

    spring特性 单例模式如何实现

    redis内存淘汰策略

    spring bean的生命周期
    https://yq.aliyun.com/articles/709422

    Redis的过期策略和内存淘汰机制
    https://www.cnblogs.com/mengchunchen/p/10039467.html

    @Bean注解,方法级别的注解,
    @Configuration注解的类里,也可以用在@Component注解的类里。
    添加的bean的id为方法名
    https://www.jianshu.com/p/06d8967b187a

    https://blog.csdn.net/qq_23179075/article/details/78753136 collections sort使用

    @Bean
    public ThreadPoolTaskExecutor asyncServiceExecutor() {
        log.info("start asyncServiceExecutor");
        
        int coreNum = Runtime.getRuntime().availableProcessors();
        log.info("the core's number of this server is "+coreNum);
        
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        //配置核心线程数
        executor.setCorePoolSize(coreNum/2+1);
        //配置最大线程数
        executor.setMaxPoolSize(coreNum+1);
        //配置队列大小
        executor.setQueueCapacity(99999);
        //配置线程池中的线程的名称前缀
        executor.setThreadNamePrefix("async-service-");
    
        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        //执行初始化
        executor.initialize();
        return executor;
    }

    相关文章

      网友评论

          本文标题:面试备忘

          本文链接:https://www.haomeiwen.com/subject/sgxpzqtx.html