ARTICLE AD BOX
I use:
@Configuration public class AsyncConfig { @Bean(name = "virtualExecutor") public ExecutorService newExecutor() { return Executors.newThreadPerTaskExecutor( Thread.ofVirtual() .name("virtual-", 0) .factory() ); } }To create virtual threads and to run:
@Autowired @Qualifier("virtualExecutor") private ExecutorService virtualExecutor; public void myFunc(){ virtualExecutor.execute(() -> { try { f1(); } catch (Exception e) { log.error("Failed", e); } }); }And:
private f1(){ for(...){ if (Thread.currentThread().isInterrupted()) { return false; } // my code } }The threads are still running after application shutdown.
Using the below code to handle termination:
Is there a solution to this? My code runs api calls using python Scripts via new ProcessBuilder()
