I have got an executor that executes a task every 5 sec
public class ScheduledTaskExecutor {
public int execute(){
ScheduledExecutorService executor = Executors.newScheduledThreadPool(4);
executor.scheduleAtFixedRate(new Task().run,3,5, TimeUnit.SECONDS);
return -1;
}
}
Here's the task. I'm throwing an IllegalArgumentException
if X == 4
public class Task {
private static final Logger LOG = LoggerFactory.getLogger(DcEmailTask.class);
private int x = 0;
public Runnable run = () -> {
String currentThread = Thread.currentThread().getName();
x++;
System.out.println("Thread [" + currentThread + "] is executing the task: " + x);
if (x == 4) throw new IllegalArgumentException();
};
}
The program stops executing and no stack trace is printed.