Search in sources :

Example 31 with Executor

use of java.util.concurrent.Executor in project flyway by flyway.

the class FlywayPerformanceMediumTest method generateLotsOfInstallerScripts.

@Before
public void generateLotsOfInstallerScripts() throws IOException {
    //noinspection ResultOfMethodCallIgnored
    new File(DIR).mkdirs();
    Executor executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
    for (int i = (scriptCount - 500); i < scriptCount; i++) {
        final int j = i;
        executor.execute(new Runnable() {

            @Override
            public void run() {
                try {
                    IOUtils.write("SELECT " + j + " FROM DUAL", new FileOutputStream(DIR + "/V" + j + "__Test.sql"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
Also used : Executor(java.util.concurrent.Executor) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) Before(org.junit.Before)

Example 32 with Executor

use of java.util.concurrent.Executor in project facebook-android-sdk by facebook.

the class FacebookSdkPowerMockTest method testSetExecutor.

@Test
public void testSetExecutor() {
    final ConditionVariable condition = new ConditionVariable();
    final Runnable runnable = new Runnable() {

        @Override
        public void run() {
        }
    };
    final Executor executor = new Executor() {

        @Override
        public void execute(Runnable command) {
            assertEquals(runnable, command);
            command.run();
            condition.open();
        }
    };
    Executor original = FacebookSdk.getExecutor();
    try {
        FacebookSdk.setExecutor(executor);
        FacebookSdk.getExecutor().execute(runnable);
        boolean success = condition.block(5000);
        assertTrue(success);
    } finally {
        FacebookSdk.setExecutor(original);
    }
}
Also used : ConditionVariable(android.os.ConditionVariable) Executor(java.util.concurrent.Executor) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 33 with Executor

use of java.util.concurrent.Executor in project fresco by facebook.

the class AbstractDataSource method notifyProgressUpdate.

protected void notifyProgressUpdate() {
    for (Pair<DataSubscriber<T>, Executor> pair : mSubscribers) {
        final DataSubscriber<T> subscriber = pair.first;
        Executor executor = pair.second;
        executor.execute(new Runnable() {

            @Override
            public void run() {
                subscriber.onProgressUpdate(AbstractDataSource.this);
            }
        });
    }
}
Also used : Executor(java.util.concurrent.Executor)

Example 34 with Executor

use of java.util.concurrent.Executor in project agera by google.

the class CompiledRepository method runGoTo.

private int runGoTo(@NonNull final Object[] directives, final int index) {
    Executor executor = (Executor) directives[index + 1];
    executor.execute(this);
    return -1;
}
Also used : Executor(java.util.concurrent.Executor)

Example 35 with Executor

use of java.util.concurrent.Executor in project hazelcast by hazelcast.

the class DelegateAndSkipOnConcurrentExecutionDecoratorTest method toString_contains_runnables_info.

@Test
public void toString_contains_runnables_info() throws Exception {
    ResumableCountingRunnable runnable = new ResumableCountingRunnable();
    Executor executor = new Executor() {

        @Override
        public void execute(Runnable command) {
        }
    };
    String stringified = new DelegateAndSkipOnConcurrentExecutionDecorator(runnable, executor).toString();
    assertTrue(stringified.contains("ResumableCountingRunnable"));
}
Also used : Executor(java.util.concurrent.Executor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

Executor (java.util.concurrent.Executor)302 Test (org.junit.Test)127 ArrayList (java.util.ArrayList)35 CountDownLatch (java.util.concurrent.CountDownLatch)32 IOException (java.io.IOException)29 List (java.util.List)27 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)22 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)17 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 Map (java.util.Map)15 Timeouts (org.neo4j.cluster.timeout.Timeouts)15 ExecutorService (java.util.concurrent.ExecutorService)13 InstanceId (org.neo4j.cluster.InstanceId)13 Config (org.neo4j.kernel.configuration.Config)13 File (java.io.File)12 ObjectInputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectInputStreamFactory)12 ObjectOutputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectOutputStreamFactory)12 HeartbeatContext (org.neo4j.cluster.protocol.heartbeat.HeartbeatContext)12 InetSocketAddress (java.net.InetSocketAddress)10