Package java.util.concurrent

Examples of java.util.concurrent.Future.cancel()


        assertNull(out);
    }

    public void testConvertFutureCancelledThenOkay() {
        Future future = template.asyncRequestBody("direct:foo", "Hello World");
        future.cancel(true);

        Object out = context.getTypeConverter().convertTo(String.class, future);
        // should be null since its cancelled
        assertNull(out);
View Full Code Here


            } else {
                future.get();
            }
        } catch (TimeoutException e) {
            // timeout then cancel the task
            future.cancel(true);

            // if set, stop processing and return false to indicate that the shutdown is aborting
            if (abortAfterTimeout) {
                LOG.warn("Timeout occurred. Aborting the shutdown now.");
                return false;
View Full Code Here

        Future f = new GDataIndexer.FinishingFuture();
        assertNull(f.get());
        assertNull(f.get(0,TimeUnit.MICROSECONDS));
        assertTrue(f.isDone());
        assertFalse(f.isCancelled());
        assertFalse(f.cancel(true));
       
    }

  
View Full Code Here

            } else {
                future.get();
            }
        } catch (TimeoutException e) {
            // timeout then cancel the task
            future.cancel(true);

            // if set, stop processing and return false to indicate that the shutdown is aborting
            if (abortAfterTimeout) {
                LOG.warn("Timeout occurred. Aborting the shutdown now.");
                return false;
View Full Code Here

    // 取消一下当前正在执行的异步任务
    private void cancel(List<Future> futures) {
        for (int i = 0; i < futures.size(); i++) {
            Future future = futures.get(i);
            if (future.isDone() == false) {
                future.cancel(true);// 中断之前的操作
            }
        }
    }

    // 调整一下线程池
View Full Code Here

        assertNull(out);
    }

    public void testConvertFutureCancelled() {
        Future future = template.asyncRequestBody("direct:foo", "Hello World");
        future.cancel(true);

        Object out = context.getTypeConverter().convertTo(String.class, future);
        // should be null since its cancelled
        assertNull(out);
    }
View Full Code Here

        assertNull(out);
    }

    public void testConvertFutureCancelledThenOkay() {
        Future future = template.asyncRequestBody("direct:foo", "Hello World");
        future.cancel(true);

        Object out = context.getTypeConverter().convertTo(String.class, future);
        // should be null since its cancelled
        assertNull(out);
View Full Code Here

            } else {
                future.get();
            }
        } catch (TimeoutException e) {
            // timeout then cancel the task
            future.cancel(true);

            // if set, stop processing and return false to indicate that the shutdown is aborting
            if (abortAfterTimeout) {
                LOG.warn("Timeout occurred. Aborting the shutdown now.");
                return false;
View Full Code Here

    public void cancel() {
        logger.info("canal Futures[{}]", futures.size());
        for (int i = 0; i < futures.size(); i++) {
            Future future = futures.get(i);
            if (!future.isDone() && !future.isCancelled()) {
                future.cancel(true);
            }
        }
    }

    // 调整一下线程池
View Full Code Here

    synchronized (monitoredFutures) {
      Iterator it = monitoredFutures.iterator();
      while (it.hasNext()) {
        Future future = (Future) it.next();
        if (!future.equals(successFuture)) {
          future.cancel(true);
        }
      }
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.