How can I wrap a method so that I can kill its execution if it exceeds a specified timeout?
I have a method that I would like to call. However, I'm looking for a clean, simple way to kill it or force it to return if it is taking too long to execute. I'm using Java. to illustrate: logger.info("sequentially executing all batches..."); for (TestExecutor executor : builder.getExecutors()) { logger.info("executing batch..."); executor.execute(); } I figure the TestExecutor class should implement Callable and continue in that direction. But all i want to be able to do is stop executor.execute() if it's taking too long. Suggestions...? EDIT Many of the suggestions received assume that the