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:org.jbpm.instance.migration.HibernateTestSupport.java

public void runInTransaction(Runnable runnable) {
    Transaction transaction = getSessionFactory().getCurrentSession().beginTransaction();
    runnable.run();
    transaction.commit();// w w  w. j  a v a  2 s.  co m
}

From source file:com.contentful.vaultintegration.BaseTest.java

protected void sync(SyncConfig config) throws InterruptedException {
    if (config == null) {
        config = SyncConfig.builder().setClient(client).build();
    }/*from w  w  w.  j a v a 2s .  c o m*/

    final CountDownLatch latch = new CountDownLatch(1);

    Executor executor = new Executor() {
        @Override
        public void execute(Runnable command) {
            command.run();
        }
    };

    final SyncResult[] result = { null };
    SyncCallback callback = new SyncCallback() {
        @Override
        public void onResult(SyncResult r) {
            result[0] = r;
            latch.countDown();
        }
    };

    vault.requestSync(config, callback, executor);
    latch.await();

    assertThat(result[0]).isNotNull();

    if (!result[0].isSuccessful()) {
        throw (RuntimeException) result[0].error();
    }
}

From source file:com.vaadin.spring.framework7.samples.TrivialNavigationComponent.java

private void addButton(String id, String caption, Runnable action, String notificationText) {
    NativeButton button = new NativeButton(caption, clickEvent -> {
        action.run();
        if (notificationText != null)
            Notification.show(notificationText);
    });/*  w  w  w .  ja v a2  s .c om*/
    button.setId(id);
    addComponent(button);
}

From source file:com.eclecticlogic.pedal.impl.TransactionImpl.java

@Override
public void run(Runnable block) {
    _exec(context -> {
        block.run();
        return null;
    });
}

From source file:br.com.suricattus.surispring.spring.scope.ViewScope.java

public Object remove(String name) {
    Object instance = getBeansMap().remove(name);
    if (instance != null) {
        Runnable callback = getCallbacksMap().remove(name);
        if (callback != null) {
            callback.run();
        }/*from w  w w .ja v a2s.c  om*/
    }
    return instance;
}

From source file:org.jruby.rack.mock.MockAsyncContext.java

@Override
public void dispatch(ServletContext context, String path) {
    this.dispatchedPath = path;
    for (Runnable r : this.dispatchHandlers) {
        r.run();
    }//  w  w  w. j a v a2 s.  c  o m
}

From source file:org.springsource.sinspctr.InspctrServer.java

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

From source file:edu.umn.msi.tropix.common.io.impl.AsyncStreamCopierImplTest.java

private void testSimpleCopy(final boolean close) {
    final AsyncStreamCopierImpl copier = new AsyncStreamCopierImpl();
    final ByteArrayInputStream inputStream = new ByteArrayInputStream("Hello".getBytes());
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    final TrackedOutputStream trackedOutputStream = new TrackedOutputStream(outputStream);
    copier.setExecutor(new Executor() {
        public void execute(final Runnable runnable) {
            runnable.run();
        }// w w  w.ja v  a 2  s  .c  o m
    });
    copier.copy(inputStream, trackedOutputStream, close);
    assert new String(outputStream.toByteArray()).equals("Hello");
    assert trackedOutputStream.closed == close;
}

From source file:guru.qas.martini.scope.ScenarioScope.java

protected void run(String name, Runnable callback) {
    try {//from ww  w .j a  v a 2  s. co m
        callback.run();
    } catch (Exception e) {
        logger.warn("unable to complete destruction callback for bean {}", name, e);
    }
}

From source file:org.age.services.lifecycle.internal.DefaultNodeLifecycleService.java

@Override
public void stop(final Runnable runnable) {
    stop();
    runnable.run();
}