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.android.volley.utils.ImmediateResponseDelivery.java

public ImmediateResponseDelivery() {
    super(new Executor() {
        @Override//from w w  w .  j av  a  2  s.c  o m
        public void execute(Runnable command) {
            command.run();
        }
    });
}

From source file:com.erinors.hpb.tests.integration.PersistenceServiceImpl.java

@Override
@Transactional
public void executeTransactionally(Runnable task) {
    task.run();
}

From source file:org.ngrinder.infra.transaction.TransactionService.java

/**
 * Run #runnable.run() in transaction context.
 *
 * @param runnable runnable// w w  w.  j av a 2  s  .  com
 */
@Transactional
public void runInTransaction(Runnable runnable) {
    runnable.run();
}

From source file:com.haulmont.cuba.web.gui.components.WebComponentsHelper.java

@Deprecated
public static void addEnterShortcut(TextField textField, final Runnable runnable) {
    CubaTextField cubaTextField = (CubaTextField) WebComponentsHelper.unwrap(textField);
    cubaTextField.addShortcutListener(/*from  w w  w.ja  v a 2 s.  c o m*/
            new ShortcutListener("", ShortcutAction.KeyCode.ENTER, KeyCombination.Modifier.codes()) {
                @Override
                public void handleAction(Object sender, Object target) {
                    runnable.run();
                }
            });
}

From source file:ar.com.zauber.commons.dao.impl.ListRunnable.java

/** @see Runnable#run() */
public final void run() {
    for (final Runnable r : runnables) {
        r.run();
    }// ww  w. ja v a2 s .  c  o m
}

From source file:net.sf.cindy.impl.SimpleDispatcher.java

public void dispatch(Session session, Runnable runnable) {
    try {//  ww  w.  j a  v  a  2s  .  com
        runnable.run();
    } catch (Exception e) { // protection catch
        log.error(e, e);
    }
}

From source file:net.gtaun.wl.race.dialog.TrackDialog.java

public static WlListDialog create(Player player, EventManager eventManager, AbstractDialog parent,
        RaceServiceImpl service, Track track) {
    PlayerStringSet stringSet = service.getLocalizedStringSet().getStringSet(player);
    RacingManagerImpl racingManager = service.getRacingManager();

    return WlListDialog.create(player, eventManager).parentDialog(parent)
            .caption(() -> stringSet.format("Dialog.TrackDialog.Caption", track.getName()))

            .item(() -> stringSet.format("Dialog.TrackDialog.Name", track.getName()),
                    (i) -> i.getCurrentDialog().show())
            .item(() -> stringSet.format("Dialog.TrackDialog.Author", track.getAuthorUniqueId()),
                    (i) -> i.getCurrentDialog().show())

            .item(() -> {/* w  ww .  j a v  a 2  s  . c  om*/
                String desc = track.getDesc();
                if (StringUtils.isBlank(desc))
                    desc = stringSet.get("Common.Empty");
                return stringSet.format("Dialog.TrackDialog.Desc", StringUtils.abbreviate(desc, 60));
            }, (i) -> {
                i.getCurrentDialog().show();
            })

            .item(() -> stringSet.format("Dialog.TrackDialog.Status", track.getStatus()),
                    (i) -> i.getCurrentDialog().show())
            .item(() -> stringSet.format("Dialog.TrackDialog.Checkpoints", track.getCheckpoints().size()),
                    (i) -> i.getCurrentDialog().show())
            .item(() -> stringSet.format("Dialog.TrackDialog.Length", track.getLength() / 1000.0f),
                    (i) -> i.getCurrentDialog().show())
            .item(() -> stringSet.format("Dialog.TrackDialog.Distance",
                    player.getLocation().distance(track.getStartLocation())),
                    (i) -> i.getCurrentDialog().show())

            .item(() -> stringSet.get("Dialog.TrackDialog.Edit"), () -> {
                if (track.getStatus() == TrackStatus.RANKING)
                    return false;
                if (player.isAdmin())
                    return true;
                return player.getName().equalsIgnoreCase(track.getAuthorUniqueId());
            }, (i) -> {
                if (track.getStatus() == TrackStatus.COMPLETED) {
                    String caption = stringSet.get("Dialog.TrackEditConfirmDialog.Caption");
                    String text = stringSet.format("Dialog.TrackEditConfirmDialog.Text", track.getName());

                    MsgboxDialog.create(player, eventManager).parentDialog(i.getCurrentDialog())
                            .caption(caption).message(text).onClickOk((d) -> {
                                player.playSound(1083);
                                service.editTrack(player, track);
                            }).build().show();
                } else if (track.getStatus() == TrackStatus.RANKING) {
                    i.getCurrentDialog().show();
                } else {
                    service.editTrack(player, track);
                }
            })

            .item(() -> stringSet.get("Dialog.TrackDialog.Test"), () -> {
                if (track.getCheckpoints().isEmpty())
                    return false;
                return track.getStatus() == TrackStatus.EDITING;
            }, (i) -> {
                Runnable startNewRacing = () -> {
                    Racing racing = racingManager.createRacing(track, player,
                            RacingUtils.getDefaultName(player, track));
                    racing.teleToStartingPoint(player);
                    racing.beginCountdown();
                };

                List<TrackCheckpoint> checkpoints = track.getCheckpoints();
                if (checkpoints.isEmpty())
                    return;

                if (racingManager.isPlayerInRacing(player)) {
                    Racing racing = racingManager.getPlayerRacing(player);
                    NewRacingConfirmDialog
                            .create(player, eventManager, i.getCurrentDialog(), service, racing, () -> {
                                startNewRacing.run();
                            }).show();
                } else
                    startNewRacing.run();
            })

            .item(() -> stringSet.get("Dialog.TrackDialog.NewRacing"), () -> {
                if (track.getCheckpoints().isEmpty())
                    return false;
                return track.getStatus() != TrackStatus.EDITING;
            }, (i) -> {
                NewRacingDialog.create(player, eventManager, i.getCurrentDialog(), service, track).show();
            })

            .item(() -> stringSet.get("Dialog.TrackDialog.QuickNewRacing"), () -> {
                if (track.getCheckpoints().isEmpty())
                    return false;
                return track.getStatus() != TrackStatus.EDITING;
            }, (i) -> {
                Runnable startNewRacing = () -> {
                    Racing racing = racingManager.createRacing(track, player,
                            RacingUtils.getDefaultName(player, track));
                    racing.teleToStartingPoint(player);
                };

                if (racingManager.isPlayerInRacing(player)) {
                    Racing racing = racingManager.getPlayerRacing(player);
                    String caption = stringSet.get("Dialog.TrackNewRacingConfirmDialog.Caption");
                    String text = stringSet.format("Dialog.TrackNewRacingConfirmDialog.Text", racing.getName());

                    WlMsgboxDialog.create(player, eventManager).parentDialog(parent).caption(caption)
                            .message(text).onClickOk((d) -> {
                                player.playSound(1083);
                                racing.leave(player);
                                startNewRacing.run();
                            }).build().show();
                } else
                    startNewRacing.run();
            })

            .onClickOk((d, i) -> player.playSound(1083)).build();
}

From source file:ThreadTask.java

public void run() {
    while (true) {
        // blocks until job
        Runnable job = pool.getNext();
        try {/*from  w  w w .  j  a  v a 2 s  . c  o m*/
            job.run();
        } catch (Exception e) {
            // Ignore exceptions thrown from jobs
            System.err.println("Job exception: " + e);
        }
    }
}

From source file:com.juhuasuan.osprey.DIYExecutor.java

public void execute(Runnable task) {
    if (null != task) {
        task.run();
    } else {/*w w  w  .j  av  a 2 s.  c om*/
        LOGGER.warn(Thread.currentThread().getName() + " DIYExecutor task is null.");
    }
}

From source file:io.fabric8.kubeflix.TurbineLifecycle.java

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