Problem using ScheduledExecutorService in Listener contextInitialized method
I try to run a thread (class AlertManager implements Runnable) with ScheduledExecutorService, writing this code in a Listener contextInitialized method:
When I deploy war file on Tomcat, deploy doesn't end. In catalina.log file I can read the AlertManager thread log information, replaced subsequently with the given period. But the execution of contextInitialized method doesn't end, deploy can't finish.
Runnable alertTask = new AlertManager();
ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
ScheduledFuture<?> scheduledFuture = scheduledExecutorService.scheduleAtFixedRate(
If I use classic implementation, it works!
Can you help me?
Runnable runnable = new AlertManager();
Thread thread = new Thread(runnable);