How it works...

If you have been through the last recipe, you will already be familiar with the Callable task, so I won't give you more details about it here. But now, we are implementing our task using both the Callable and ManagedTaskListener interfaces. The second one gives us all the methods for checking the task's status:

    @Override    public void taskSubmitted(Future<?> future,     ManagedExecutorService mes, Object o) {        long mili = new Date().getTime();        LOG.log(Level.INFO, "taskSubmitted: {0} -         Miliseconds since instantiation: {1}",         new Object[]{future, mili - instantiationMili});    }    @Override    public void taskAborted(Future<?> future,     ManagedExecutorService mes, Object o, Throwable thrwbl) {        long mili = new Date().getTime(); LOG.log(Level.INFO, ...

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.