public < T > T executeAbortable ( ExecutorService exec , Callable < T > callable ) throws IOException , InterruptedException , ExecutionException { Future < T > task = exec . submit ( callable ) ; waitAbortable ( task ) ; return task . get ( ) ; }
Execute callable which may not be interruptable by itself but listen to terminal input and abort the task if CTRL - C is pressed .