当前位置: 首页>>代码示例>>Java>>正文


Java ScheduledFuture.get方法代码示例

本文整理汇总了Java中java.util.concurrent.ScheduledFuture.get方法的典型用法代码示例。如果您正苦于以下问题:Java ScheduledFuture.get方法的具体用法?Java ScheduledFuture.get怎么用?Java ScheduledFuture.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.ScheduledFuture的用法示例。


在下文中一共展示了ScheduledFuture.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testScheduleWithDelay

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Test
public void testScheduleWithDelay() throws ExecutionException, InterruptedException {
  MockRunLoop runLoop = new MockRunLoop();
  try {
    assertEquals(0, runLoop.getThreadPool().getCorePoolSize());
    ScheduledFuture future = runLoop.schedule(new Runnable() {
      @Override
      public void run() {
      }
    }, 500L);
    assertEquals(1, runLoop.getThreadPool().getCorePoolSize());

    future.get();
    assertTrue(runLoop.errors.isEmpty());
  } finally {
    runLoop.getExecutorService().shutdownNow();
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:19,代码来源:DefaultRunLoopTest.java

示例2: testMultipleTasksWithTimeShift

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Test
public void testMultipleTasksWithTimeShift() throws InterruptedException, ExecutionException {
    RScheduledExecutorService executor = redisson.getExecutorService("test");
    ScheduledFuture<?> future1 = executor.schedule(new ScheduledRunnableTask("executed1"), 2, TimeUnit.SECONDS);
    ScheduledFuture<?> future2 = executor.schedule(new ScheduledRunnableTask("executed2"), 3, TimeUnit.SECONDS);
    ScheduledFuture<?> future3 = executor.schedule(new ScheduledRunnableTask("executed3"), 4, TimeUnit.SECONDS);
    long startTime = System.currentTimeMillis();
    future1.get();
    assertThat(System.currentTimeMillis() - startTime).isBetween(2000L, 2200L);
    future2.get();
    assertThat(System.currentTimeMillis() - startTime).isBetween(3000L, 3200L);
    future3.get();
    assertThat(System.currentTimeMillis() - startTime).isBetween(4000L, 4200L);
    assertThat(redisson.getAtomicLong("executed1").get()).isEqualTo(1);
    assertThat(redisson.getAtomicLong("executed2").get()).isEqualTo(1);
    assertThat(redisson.getAtomicLong("executed3").get()).isEqualTo(1);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:18,代码来源:RedissonScheduledExecutorServiceTest.java

示例3: run

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Override
public void run()
{
    try
    {
        logger.info("Start feed collect");
        ScheduledFuture<Feed> future = Executors.newSingleThreadScheduledExecutor()
                                                .schedule(new YouTubeParser(),
                                                          0,
                                                          TimeUnit.MICROSECONDS);

        Feed feed = future.get();
        logger.info("Feed was collect. Feed size: {}", feed.getVideos().size());
        logger.info("Start collect images");
        imageCollector.collectImages(feed);
        LastFeedContainer.setFeed(feed);
    }
    catch (Exception e)
    {
        logger.error("Error", e);
    }
}
 
开发者ID:AnatoliyKozlov,项目名称:YouTrends,代码行数:23,代码来源:FeedParserRunnable.java

示例4: cancel

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
private void cancel(ScheduledFuture<?> future1) throws InterruptedException, ExecutionException {
    assertThat(future1.cancel(true)).isTrue();
    boolean canceled = false;
    try {
        future1.get();
    } catch (CancellationException e) {
        canceled = true;
    }
    assertThat(canceled).isTrue();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:11,代码来源:RedissonScheduledExecutorServiceTest.java

示例5: testMultipleTasks

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Test
public void testMultipleTasks() throws InterruptedException, ExecutionException {
    RScheduledExecutorService executor = redisson.getExecutorService("test");
    ScheduledFuture<?> future1 = executor.schedule(new ScheduledRunnableTask("executed1"), 5, TimeUnit.SECONDS);
    ScheduledFuture<?> future2 = executor.schedule(new ScheduledRunnableTask("executed2"), 5, TimeUnit.SECONDS);
    ScheduledFuture<?> future3 = executor.schedule(new ScheduledRunnableTask("executed3"), 5, TimeUnit.SECONDS);
    long startTime = System.currentTimeMillis();
    future1.get();
    future2.get();
    future3.get();
    assertThat(System.currentTimeMillis() - startTime).isBetween(5000L, 5200L);
    assertThat(redisson.getAtomicLong("executed1").get()).isEqualTo(1);
    assertThat(redisson.getAtomicLong("executed2").get()).isEqualTo(1);
    assertThat(redisson.getAtomicLong("executed3").get()).isEqualTo(1);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:16,代码来源:RedissonScheduledExecutorServiceTest.java

示例6: testRunnableTask

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Test
public void testRunnableTask() throws InterruptedException, ExecutionException {
    RScheduledExecutorService executor = redisson.getExecutorService("test");
    ScheduledFuture<?> future = executor.schedule(new ScheduledRunnableTask("executed"), 5, TimeUnit.SECONDS);
    long startTime = System.currentTimeMillis();
    future.get();
    assertThat(System.currentTimeMillis() - startTime).isBetween(5000L, 5200L);
    assertThat(redisson.getAtomicLong("executed").get()).isEqualTo(1);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:10,代码来源:RedissonScheduledExecutorServiceTest.java

示例7: testCallableTask

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Test
public void testCallableTask() throws InterruptedException, ExecutionException {
    RScheduledExecutorService executor = redisson.getExecutorService("test");
    ScheduledFuture<Long> future = executor.schedule(new ScheduledCallableTask(), 3, TimeUnit.SECONDS);
    long startTime = System.currentTimeMillis();
    future.get();
    assertThat(System.currentTimeMillis() - startTime).isBetween(3000L, 3200L);
    assertThat(future.get()).isEqualTo(100);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:10,代码来源:RedissonScheduledExecutorServiceTest.java

示例8: get

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
@Override
public Object get() throws InterruptedException, ExecutionException {
	ScheduledFuture<?> curr;
	synchronized (this.triggerContextMonitor) {
		curr = this.currentFuture;
	}
	return curr.get();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:ReschedulingRunnable.java

示例9: logNotifification

import java.util.concurrent.ScheduledFuture; //导入方法依赖的package包/类
/**
 * Logs the deletion of the bearer
 * @param schedFuture
 */
private static void logNotifification(ScheduledFuture<DeleteBearerCall> schedFuture)
{
	DeleteBearerCall bearerInstance = null;
	try {
		bearerInstance = schedFuture.get();
		LOG.info("Context delete success for  DPNTopic: {}, teid: {}", bearerInstance.dpnTopic, bearerInstance.s1u_sgw_gtpu_teid);
	} catch (InterruptedException | ExecutionException e) {
		ErrorLog.logError(e.getStackTrace());
       }

	/*** North bound cache notification code here**/

}
 
开发者ID:opendaylight,项目名称:fpc,代码行数:18,代码来源:DeleteContextScheduler.java


注:本文中的java.util.concurrent.ScheduledFuture.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。