0

I'd like to execute a specific method with a timeout. The wrapper method should block as long as the timeout method is still running.

How could I best achieve this, preferably using Spring?

public boolean run() {
    long start = System.currentTimeMillis();
    try {
        executeWithTimeout(); //how?
    } catch (TimeoutException e) {
        long end = System.currentTimeMillis();
        log.info("method could not complete");
        return false;
    }

    return true; //block as long as the method above is still running
}
membersound
  • 74,158
  • 163
  • 522
  • 986

0 Answers0