生成的线程数

时间:2017-10-30 07:25:54

标签: java threadpool servletcontextlistener

我想让我的监听器运行多次,这是我的解决方案,但我想这会产生问题,内存中的线程数量会非常大吗?

Timer timer = new Timer();
        executor = Executors.newSingleThreadScheduledExecutor();
        timer.schedule(new TimerTask() {

            @Override
            public void run() {

                scheduleTime = Config.NILEDOX_INBOUND_AUTOIMPORT_ROTATE;

                if(scheduleTime>=1){

                    /** setup single thread to run background service every x minutes **/

                    service = new AutoInboundMailImportService();
                    executor.scheduleWithFixedDelay(service,1,1,TimeUnit.MINUTES);


            }
        }}, 120000, 60000);

任何想法?

0 个答案:

没有答案