Java Code Examples for java.util.concurrent.ScheduledExecutorService.execute()

The following are Jave code examples for showing how to use execute() of the java.util.concurrent.ScheduledExecutorService class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: swage   File: StateCaptureTest.java   Source Code and License Vote up 5 votes
@Test
public void testScheduledExecutorServiceCaptures() throws InterruptedException {
    // Setup
    ScheduledExecutorService e = Executors.newScheduledThreadPool(10);
    ScheduledExecutorService f = StateCapture.capturingDecorator(e);

    CapturedState mockCapturedState = mock(CapturedState.class);
    Runnable mockRunnable = mock(Runnable.class);
    ThreadLocalStateCaptor.THREAD_LOCAL.set(mockCapturedState);
    f.execute(mockRunnable);
    e.shutdown();
    e.awaitTermination(10, TimeUnit.HOURS);

    verifyStandardCaptures(mockCapturedState, mockRunnable);
}
 
Example 2
Project: pyplyn   File: DuctMain.java   Source Code and License Vote up 5 votes
/**
 * Only executes once then shuts down
 */
private static void runOnceMode(ScheduledExecutorService EXECUTOR, ConfigurationUpdateManager configurationManager, TaskManager<Configuration> taskManager, ShutdownHook shutdownHook) throws InterruptedException {
    // execute service once
    EXECUTOR.execute(configurationManager);

    // wait until all tasks complete and shutdown
    configurationManager.awaitUntilConfigured();
    taskManager.awaitUntilFinished();
    shutdownHook.shutdown();
}