/** {@inheritDoc} */ @Override public Serializable execute() { synchronized (mux) { execCnt++; } if (log.isInfoEnabled()) log.info("Executing job: " + jobCtx.getJobId()); long now = System.currentTimeMillis(); while (!isCancelled && now < thresholdTime) { synchronized (mux) { try { mux.wait(thresholdTime - now); } catch (InterruptedException ignored) { // No-op. } } now = System.currentTimeMillis(); } synchronized (mux) { return isCancelled ? 1 : 0; } }
/** {@inheritDoc} */ @Override public void cancel() { synchronized (mux) { isCancelled = true; cancelCnt++; mux.notifyAll(); } log.warning("Job cancelled: " + jobCtx.getJobId()); }