List of usage examples for java.lang Runnable run
public abstract void run();
Runnable
is used to create a thread, starting the thread causes the object's run
method to be called in that separately executing thread. From source file:au.com.addstar.SpigetUpdater.java
@Override protected void dispatch(Runnable runnable) { runnable.run(); }
From source file:net.brtly.monkeyboard.gui.MasterControlPanel.java
private void initWindowListener(final JFrame frame) { frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent e) { }/*from w w w.ja v a2 s .c om*/ public void windowClosing(WindowEvent e) { frame.dispose(); } public void windowClosed(WindowEvent e) { for (Runnable onClose : _runOnClose) { onClose.run(); } } }); }
From source file:fr.norad.visuwall.core.business.process.WallProcess.java
public void rebuildFullWallInformations(final Wall wall) { taskScheduler.schedule(new Runnable() { @Override/*from w w w . j a v a 2 s . co m*/ public void run() { // TODO prevent wall hiding (exception causing wall not added to wall list) if software not found rebuildConnectionPluginsInSoftwareAccess(wall); for (SoftwareAccess softwareAccess : wall.getSoftwareAccesses()) { if (softwareAccess.getConnection() instanceof BuildCapability) { Runnable task = getDiscoverBuildProjectsRunner(wall, softwareAccess); task.run(); // TODO skip first immediate schedule run as called by hand upper @SuppressWarnings("unchecked") ScheduledFuture<Object> futur = taskScheduler.scheduleWithFixedDelay(task, softwareAccess.getProjectFinderDelaySecond() * 1000); softwareAccess.setProjectFinderTask(futur); } } // here as task war run ones without schedule, projects exists, we need that for first run // to add other software without waiting for the second project discover for (SoftwareAccess softwareAccess : wall.getSoftwareAccesses()) { if (!(softwareAccess.getConnection() instanceof BuildCapability)) { Runnable task = getDiscoverOtherProjectsRunner(wall, softwareAccess); task.run(); // TODO skip first immediate schedule run as called by hand upper @SuppressWarnings("unchecked") ScheduledFuture<Object> futur = taskScheduler.scheduleWithFixedDelay(task, softwareAccess.getProjectFinderDelaySecond() * 1000); softwareAccess.setProjectFinderTask(futur); } } } }, new Date()); }
From source file:SwingThreading.java
private void incrementLabel() { tickCounter++;/*from w w w . j a va 2s .co m*/ Runnable code = new Runnable() { public void run() { counter.setText(String.valueOf(tickCounter)); } }; if (SwingUtilities.isEventDispatchThread()) { code.run(); } else { SwingUtilities.invokeLater(code); } }
From source file:example.tests.SpaceObjectWriteSynchronizationTest.java
private void assertEventuallyPasses(Runnable test) throws InterruptedException { long timeout = System.currentTimeMillis() + 10_000; while (true) { try {/* w w w . j a v a2 s . com*/ test.run(); return; // Test passed, return } catch (AssertionError e) { // Test failed if (System.currentTimeMillis() > timeout) { throw e; } else { Thread.sleep(100); } } } }
From source file:org.apache.zeppelin.lens.LensJLineShellComponent.java
public void stop(Runnable callback) { stop(); callback.run(); }
From source file:org.jdal.vaadin.beans.VaadinScope.java
private void removeBeans(UI ui) { Set<String> keys = beans.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { String key = iter.next(); String prefix = getConversationId(ui); if (key.startsWith(prefix)) { iter.remove();/*from www . j a v a2s . c o m*/ if (log.isDebugEnabled()) log.debug("Removed bean [" + key + "]"); Runnable callback = callbacks.remove(key); if (callback != null) { callback.run(); } } } }
From source file:com.thoughtworks.go.util.GoConfigFileHelper.java
public static void withServerIdImmutability(Runnable fn) { try {/*from w ww . j a v a 2 s. co m*/ SystemEnvironment.enforceServerImmutability.set(true); fn.run(); } finally { SystemEnvironment.enforceServerImmutability.set(false); } }
From source file:at.ac.univie.isc.asio.brood.Warden.java
/** * Stop the Warden asynchronously, same as calling {@link #stop()}, then run the supplied * callback./*from ww w . ja va 2s . co m*/ */ @Override public void stop(final Runnable callback) { stop(); callback.run(); }
From source file:com.pepaproch.gtswsdl.client.RateLimitTest.java
@Test public void testCOnsumeSLotAsync() { RateLimit rate = new RateLimit(5, 10, ChronoUnit.SECONDS); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10); final AtomicInteger cc = new AtomicInteger(0); Instant start = Instant.now(); final Instant[] end = new Instant[1]; Runnable r = () -> {//from w w w .ja v a 2 s . com for (int i = 0; i < 21; i++) { addTask(cc, scheduler, rate, end); } }; Runnable r1 = () -> { for (int i = 0; i < 9; i++) { addTask(cc, scheduler, rate, end); } }; r1.run(); r.run(); try { scheduler.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(Duration.between(start, end[0]).toMillis()); }