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


Java ScheduledThreadPoolExecutor.shutdown方法代码示例

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


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

示例1: test

import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
void test(String[] args) throws Throwable {

        ScheduledThreadPoolExecutor pool = new ScheduledThreadPoolExecutor(0);
        Runnable task = new Runnable() {
            public void run() {
                taskRun = true;
            }
        };
        check(pool.getCorePoolSize() == 0);

        pool.schedule(task, 1, TimeUnit.SECONDS);

        pool.shutdown();
        check(pool.awaitTermination(20L, TimeUnit.SECONDS));
        check(pool.getCorePoolSize() == 0);
        check(taskRun);
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:ZeroCorePoolSize.java

示例2: test

import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
void test(String[] args) throws Throwable {

        ScheduledThreadPoolExecutor pool = new ScheduledThreadPoolExecutor(0);
        Runnable task = new Runnable() {
            public void run() {
                taskRun = true;
            }
        };
        check(pool.getCorePoolSize() == 0);

        pool.schedule(task, 12L, MILLISECONDS);

        pool.shutdown();
        check(pool.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
        check(pool.getCorePoolSize() == 0);
        check(taskRun);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ZeroCorePoolSize.java

示例3: test

import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
void test(String[] args) throws Throwable {

        final ScheduledThreadPoolExecutor pool =
            new ScheduledThreadPoolExecutor(1);

        // Needed to avoid OOME
        pool.setRemoveOnCancelPolicy(true);

        final long moreThanYouCanChew = Runtime.getRuntime().freeMemory() / 4;
        System.out.printf("moreThanYouCanChew=%d%n", moreThanYouCanChew);

        Runnable noopTask = new Runnable() { public void run() {}};

        for (long i = 0; i < moreThanYouCanChew; i++)
            pool.schedule(noopTask, 10, TimeUnit.MINUTES).cancel(true);

        pool.shutdown();
        check(pool.awaitTermination(1L, TimeUnit.DAYS));
        checkTerminated(pool);
        equal(pool.getTaskCount(), 0L);
        equal(pool.getCompletedTaskCount(), 0L);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:BasicCancelTest.java

示例4: testIsShutdown

import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
/**
 * isShutdown is false before shutdown, true after
 */
public void testIsShutdown() {
    final ScheduledThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1);
    assertFalse(p.isShutdown());
    try (PoolCleaner cleaner = cleaner(p)) {
        try {
            p.shutdown();
            assertTrue(p.isShutdown());
        } catch (SecurityException ok) {}
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ScheduledExecutorTest.java

示例5: cleanUp

import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
public static void cleanUp() {
    for (ScheduledThreadPoolExecutor executor : ALLEXECUTORS) {
        executor.shutdown();
    }
    ALLEXECUTORS.clear();
    numberOfCloseMethodCalls = 0;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:TestingScheduledThreadPoolImpl.java

示例6: main

import java.util.concurrent.ScheduledThreadPoolExecutor; //导入方法依赖的package包/类
public static void main(String[] args) throws Throwable {

        final CountDownLatch count = new CountDownLatch(1000);

        final ScheduledThreadPoolExecutor pool =
            new ScheduledThreadPoolExecutor(100);
        pool.prestartAllCoreThreads();

        final Runnable incTask = new Runnable() { public void run() {
            count.countDown();
        }};

        pool.scheduleAtFixedRate(incTask, 0, 10, TimeUnit.MILLISECONDS);

        count.await();

        pool.shutdown();
        pool.awaitTermination(1L, TimeUnit.DAYS);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Stress.java


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