ExecutorService is not shutting down

前端 未结 5 468
独厮守ぢ
独厮守ぢ 2021-01-13 06:17

I have the following code

    ExecutorService es = Executors.newSingleThreadExecutor();
    es.submit(new Runnable() {
           @Override public void run()         


        
5条回答
  •  一生所求
    2021-01-13 06:54

    Please try this

    ExecutorService es = Executors.newSingleThreadExecutor();
    es.submit(new Runnable() {
           @Override public void run() 
           {
                 try{
                    while(true);
                 }catch(InterruptException){
                    Thread.currentThread().interrupt();
                 }
            }
    

    }); es.shutdownNow();

提交回复
热议问题