Multithreading: when doing unit test, use thread pool to find that the specified code is not running and skip directly

Today, we did a unit test to debug the interface. We found that the interface call was successful, but we did not run the thread pool execution method. Instead, we directly skipped the execution code

 

 ExecutorService pool = Executors.newFixedThreadPool( 2 );

 

 public void callInterfaceCreditease(final String idcard,final String name,final String mobile){
        try{
            
            ExecutorService pool = Executors.newFixedThreadPool( 2 );
            //Interface
            pool.execute(new Runnable() {
                @Override
                public void run() {
                    creditCardCrediteaseService.doFetchCreditData(name, idcard, mobile);
                }
            });
            //Release thread pool resources
            pool.shutdown();
        }catch(Exception e){
            log.error("Calling interface exceptions:",e);
        }
                
    }

 

Read More: