Example usage for java.lang Runnable run

List of usage examples for java.lang Runnable run

Introduction

In this page you can find the example usage for java.lang Runnable run.

Prototype

public abstract void run();

Source Link

Document

When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

Usage

From source file:com.github.vseguip.sweet.contacts.SweetContactSync.java

void performNetOperation(Runnable r) {
    r.run();
}

From source file:com.hp.alm.ali.Handler.java

public void finish() throws Throwable {
    Assert.assertTrue("Test timed out", async.tryAcquire(100, 2000, TimeUnit.MILLISECONDS));
    if (firstError != null) {
        throw firstError;
    }/*from w w w .  j a va  2  s  .  c  o m*/
    Assert.assertTrue("There are unresponded requests", requests.isEmpty());
    for (Runnable action : cleanup) {
        action.run();
    }
}

From source file:com.github.lothar.security.acl.jpa.multithread.MultithreadCustomerRepositoryTest.java

private void prepareTaskAs(Runnable runnable, String lastName) {
    range(0, TIMES).forEach(i -> {/*from  w w w .  j  a v a2  s  .c  o m*/
        tasks.add(() -> {
            Session.login(lastName);
            try {
                runnable.run();
            } catch (ComparisonFailure failure) {
                throw new ComparisonFailure(lastName + ": " + failure.getMessage(), failure.getExpected(),
                        failure.getActual());
            } finally {
                Session.logout();
            }
            return lastName;
        });
    });
}

From source file:com.bigdata.dastor.streaming.StreamOut.java

/**
 * Split out files for all tables on disk locally for each range and then stream them to the target endpoint.
*///from ww w .j  a  v  a  2s.c  o  m
public static void transferRanges(InetAddress target, String tableName, Collection<Range> ranges,
        Runnable callback) {
    assert ranges.size() > 0;

    logger.debug("Beginning transfer process to " + target + " for ranges " + StringUtils.join(ranges, ", "));

    /*
     * (1) dump all the memtables to disk.
     * (2) anticompaction -- split out the keys in the range specified
     * (3) transfer the data.
    */
    try {
        Table table = Table.open(tableName);
        logger.info("Flushing memtables for " + tableName + "...");
        for (Future f : table.flush()) {
            try {
                f.get();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            } catch (ExecutionException e) {
                throw new RuntimeException(e);
            }
        }
        logger.info("Performing anticompaction ...");
        /* Get the list of files that need to be streamed */
        transferSSTables(target, table.forceAntiCompaction(ranges, target), tableName); // SSTR GC deletes the file when done
    } catch (IOException e) {
        throw new IOError(e);
    } finally {
        StreamOutManager.remove(target);
    }
    if (callback != null)
        callback.run();
}

From source file:SingleThreadRequestExecutor.java

@Override
public <T> Future<T> submit(final Runnable task, final T result) {
    return executor.submit(new Runnable() {
        @Override//from w ww  .  j a va  2  s  .c  om
        public void run() {
            try {
                task.run();
            } catch (Throwable e) {
                // This normally bad code of catch on Exception is here for a *reason*.
                // Future *eats* all exceptions *silently*. This clause at least allows
                // the exception to emit noise for debugging. This is particularly pernicious
                // if you have something like a NullPointerException

                e.printStackTrace();
                throw new RuntimeException(e);
            }
        }
    }, result);
}

From source file:com.jbrisbin.vpc.jobsched.mapred.MapReduceMessageHandler.java

public void stop(Runnable callback) {
    callback.run();
}

From source file:net.orfjackal.retrolambda.test.LambdaTest.java

@Test
public void lambda_using_instance_variables() {
    Runnable lambda = () -> {
        instanceVar = 42;//ww w  . j  ava  2 s. com
    };
    lambda.run();

    assertThat(instanceVar, is(42));
}

From source file:net.orfjackal.retrolambda.test.LambdaTest.java

@Test
public void lambda_using_local_variables() {
    int[] localVar = new int[1];
    Runnable lambda = () -> {
        localVar[0] = 42;// w w  w .  j av a 2  s . c  o  m
    };
    lambda.run();

    assertThat(localVar[0], is(42));
}

From source file:fi.hsl.parkandride.core.service.UserServiceTest.java

@Test
public void password_is_required_for_admin() {
    Runnable createFn = () -> userService.createUser(admin, adminActor);

    createFn.run();
    verify(userRepository).insertUser(anyObject());

    admin.password = null;/*from ww  w .j a v a  2 s  . c  o  m*/
    assertBadPassword(createFn);
}

From source file:fi.hsl.parkandride.core.service.UserServiceTest.java

@Test
public void operator_is_not_allowed_for_admin() {
    Runnable createFn = () -> userService.createUser(admin, adminActor);

    createFn.run();
    verify(userRepository).insertUser(anyObject());

    admin.operatorId = DEFAULT_OPERATOR;
    assertOperatorNotAllowed(createFn);// w  ww.  jav a2s.  c  o m
}