Search in sources :

Example 46 with ScheduledThreadPoolExecutor

use of java.util.concurrent.ScheduledThreadPoolExecutor in project hadoop by apache.

the class SchedulerService method init.

@Override
public void init() throws ServiceException {
    int threads = getServiceConfig().getInt(CONF_THREADS, 5);
    scheduler = new ScheduledThreadPoolExecutor(threads);
    LOG.debug("Scheduler started");
}
Also used : ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)

Example 47 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 48 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 49 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 50 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)

Aggregations

ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)154 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)31 Test (org.junit.Test)26 ExecutorService (java.util.concurrent.ExecutorService)24 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)22 ThreadFactory (java.util.concurrent.ThreadFactory)15 Test (org.testng.annotations.Test)15 ArrayList (java.util.ArrayList)12 List (java.util.List)10 HashMap (java.util.HashMap)9 ServerInstance (com.linkedin.pinot.common.response.ServerInstance)8 NettyClientMetrics (com.linkedin.pinot.transport.metrics.NettyClientMetrics)8 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)8 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)8 HashedWheelTimer (io.netty.util.HashedWheelTimer)8 File (java.io.File)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)7 IOException (java.io.IOException)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7