Search in sources :

Example 26 with ScheduledThreadPoolExecutor

use of java.util.concurrent.ScheduledThreadPoolExecutor in project android_frameworks_base by ResurrectionRemix.

the class FileOperationService method onCreate.

@Override
public void onCreate() {
    // Allow tests to pre-set these with test doubles.
    if (executor == null) {
        executor = new ScheduledThreadPoolExecutor(POOL_SIZE);
    }
    if (jobFactory == null) {
        jobFactory = Job.Factory.instance;
    }
    if (DEBUG)
        Log.d(TAG, "Created.");
    mPowerManager = getSystemService(PowerManager.class);
    mNotificationManager = getSystemService(NotificationManager.class);
}
Also used : PowerManager(android.os.PowerManager) NotificationManager(android.app.NotificationManager) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)

Example 27 with ScheduledThreadPoolExecutor

use of java.util.concurrent.ScheduledThreadPoolExecutor in project jdk8u_jdk by JetBrains.

the class ZeroCorePoolSize method test.

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);
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)

Example 28 with ScheduledThreadPoolExecutor

use of java.util.concurrent.ScheduledThreadPoolExecutor in project jersey by jersey.

the class SimpleContainer method reload.

@Override
public void reload(final ResourceConfig configuration) {
    appHandler.onShutdown(this);
    appHandler = new ApplicationHandler(configuration.register(new SimpleBinder()));
    scheduler = new ScheduledThreadPoolExecutor(2, new DaemonFactory(TimeoutDispatcher.class));
    appHandler.onReload(this);
    appHandler.onStartup(this);
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) DaemonFactory(org.simpleframework.common.thread.DaemonFactory)

Example 29 with ScheduledThreadPoolExecutor

use of java.util.concurrent.ScheduledThreadPoolExecutor in project jersey by jersey.

the class JerseyCompletionStageRxInvokerTest method setUp.

@Before
public void setUp() throws Exception {
    client = ClientBuilder.newClient().register(TerminalClientRequestFilter.class);
    executor = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat("jersey-rx-client-test-%d").setUncaughtExceptionHandler(new JerseyProcessingUncaughtExceptionHandler()).build());
}
Also used : JerseyProcessingUncaughtExceptionHandler(org.glassfish.jersey.process.JerseyProcessingUncaughtExceptionHandler) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) ThreadFactoryBuilder(org.glassfish.jersey.internal.guava.ThreadFactoryBuilder) Before(org.junit.Before)

Example 30 with ScheduledThreadPoolExecutor

use of java.util.concurrent.ScheduledThreadPoolExecutor in project wildfly by wildfly.

the class SessionExpirationScheduler method createScheduledExecutor.

private static ScheduledExecutorService createScheduledExecutor(ThreadFactory factory) {
    ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, factory);
    executor.setRemoveOnCancelPolicy(true);
    executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    return executor;
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)

Aggregations

ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)298 Test (org.junit.Test)52 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)51 ThreadFactory (java.util.concurrent.ThreadFactory)36 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)35 ExecutorService (java.util.concurrent.ExecutorService)34 Before (org.junit.Before)23 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)20 Test (org.testng.annotations.Test)19 IOException (java.io.IOException)16 CountDownLatch (java.util.concurrent.CountDownLatch)16 ArrayList (java.util.ArrayList)15 List (java.util.List)15 HashMap (java.util.HashMap)12 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)11 File (java.io.File)11 ScheduledFuture (java.util.concurrent.ScheduledFuture)10 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)8 NettyClientMetrics (com.linkedin.pinot.transport.metrics.NettyClientMetrics)8 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)8