Package java.util.concurrent

Examples of java.util.concurrent.ExecutorService.execute()


        final Foo[] payloads = createFoo(testCycleCount);
        ExecutorService pool = Executors.newFixedThreadPool(20);
        long start = System.currentTimeMillis();
        for (int i = 0; i < payloads.length; i++) {
            final int finalI = i;
            pool.execute(new Runnable() {
                public void run() {
                    template.sendBody(payloads[finalI]);
                }
            });
        }
View Full Code Here


                logger_.debug("Running " + message.getMessageType() + " on default stage");
            messageDeserializerExecutor_.execute(runnable);
        }
        else
        {
            stage.execute(runnable);
        }
    }

    public static IAsyncCallback getRegisteredCallback(String key)
    {
View Full Code Here

        final CountDownLatch doneSignal =
                new CountDownLatch(CONCURRENT_RANDOM_OPERATIONS);

        for (int i = 0; i < CONCURRENT_RANDOM_OPERATIONS; i++) {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (numberGenerator.nextInt(2) == 0) {
                            DatasetGraphTxn txnGraph =
View Full Code Here

        for (int i = 0; i < numberOfMks; i++) {
            String diff = buildPyramidDiff("/", 0, numberOfChildren,
                    numberOfNodes, prefixes[i], new StringBuilder()).toString();
            MongoMK mk = new MongoMK.Builder().open();
            GenericWriteTask task = new GenericWriteTask("mk-" + i, mk, diff, 10);
            executor.execute(task);
        }
        executor.shutdown();
        executor.awaitTermination(10, TimeUnit.MINUTES);
    }
View Full Code Here

                    Worker[] workers = new Worker[clientsCount];
                    for (int i = 0; i < clientsCount; ++i)
                    {
                        workers[i] = new Worker(barrier, requestsCount, sessionCookie, urls);
                        workers[i].start();
                        executor.execute(workers[i]);
                    }
                    // Wait for all workers to be ready
                    barrier.await();
                    long start = System.nanoTime();
View Full Code Here

                        Worker[] workers = new Worker[clientsCount];
                        for ( int i = 0; i < clientsCount; ++i )
                        {
                            workers[i] = new Worker( barrier, requestsCount, sessionCookie, urls );
                            workers[i].start();
                            executor.execute( workers[i] );
                        }
                        // Wait for all workers to be ready
                        barrier.await();
                        long start = System.nanoTime();
View Full Code Here

        CompletableFuture<List<Integer>> emittedFrom1Final = new CompletableFuture<>();
        CompletableFuture<List<String>> emissionThreads2Final = new CompletableFuture<>();
        CompletableFuture<List<String>> emissionThreads1Final = new CompletableFuture<>();

        CountDownLatch subscribed = new CountDownLatch(2);
        exec2.execute(() -> {
            stream2.subscribe(i -> {
                if(i != null) {
                    emittedFrom2.add(i);
                    emissionThreads2.add(Thread.currentThread().getName());
                } else {
View Full Code Here

        EventSource<Integer> source = new EventSource<>();
        EventStream<Integer> divided = source.map(x -> 5/x);
        EventStream<Integer> bridged = divided.threadBridge(ex1, ex2);
        List<Throwable> errors = new ArrayList<>();
        CompletableFuture<Integer> nErrors = new CompletableFuture<>();
        ex2.execute(() -> {
            bridged.pin();
            bridged.errors().subscribe(errors::add);
            ex1.execute(() -> {
                source.push(0);
                ex2.execute(() -> nErrors.complete(errors.size()));
View Full Code Here

        ex2.execute(() -> {
            bridged.pin();
            bridged.errors().subscribe(errors::add);
            ex1.execute(() -> {
                source.push(0);
                ex2.execute(() -> nErrors.complete(errors.size()));
            });
        });

        assertEquals(1, nErrors.get().intValue());
View Full Code Here

    @Test
    public void executorTest() throws InterruptedException, ExecutionException {
        ExecutorService executor = Executors.newSingleThreadExecutor();

        CompletableFuture<Integer> nTicks = new CompletableFuture<>();
        executor.execute(() -> {
            EventCounter counter = new EventCounter();
            Subscription sub = EventStreams.ticks(Duration.ofMillis(100), scheduler, executor).subscribe(counter);
            ScheduledExecutorServiceTimer.create(Duration.ofMillis(350), sub::unsubscribe, scheduler, executor).restart(); // stop after 3 ticks
            // wait a little more to test that no more than 3 ticks arrive anyway
            ScheduledExecutorServiceTimer.create(Duration.ofMillis(550), () -> nTicks.complete(counter.get()), scheduler, executor).restart();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.