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:de.micromata.genome.db.jpa.genomecore.chronos.JpaJobStore.java
@Override public void withinTransaction(final Runnable runnable) { emfac.runInTrans(new EmgrCallable<Void, DefaultEmgr>() { @Override//from w ww. j av a 2 s . co m public Void call(DefaultEmgr emgr) { runnable.run(); // NOSONAR false positive return null; } }); }
From source file:gov.va.isaac.sync.view.SyncView.java
private void addLine(String line) { Runnable work = new Runnable() { @Override/* www.ja va2 s . co m*/ public void run() { summary_.setText(summary_.getText() + line + "\n"); } }; if (Platform.isFxApplicationThread()) { work.run(); } else { Platform.runLater(work); } }
From source file:net.sf.mzmine.project.impl.StorableScan.java
@Override public synchronized void addMassList(final @Nonnull MassList massList) { // Remove all mass lists with same name, if there are any MassList currentMassLists[] = massLists.toArray(new MassList[0]); for (MassList ml : currentMassLists) { if (ml.getName().equals(massList.getName())) removeMassList(ml);// w w w . j a va2 s .com } StorableMassList storedMassList; if (massList instanceof StorableMassList) { storedMassList = (StorableMassList) massList; } else { DataPoint massListDataPoints[] = massList.getDataPoints(); try { int mlStorageID = rawDataFile.storeDataPoints(massListDataPoints); storedMassList = new StorableMassList(rawDataFile, mlStorageID, massList.getName(), this); } catch (IOException e) { logger.severe("Could not write data to temporary file " + e.toString()); return; } } // Add the new mass list massLists.add(storedMassList); // Add the mass list to the tree model MZmineProjectImpl project = (MZmineProjectImpl) MZmineCore.getCurrentProject(); // Check if we are adding to the current project if (Arrays.asList(project.getDataFiles()).contains(rawDataFile)) { final RawDataTreeModel treeModel = project.getRawDataTreeModel(); final MassList newMassList = storedMassList; Runnable swingCode = new Runnable() { @Override public void run() { treeModel.addObject(newMassList); } }; try { if (SwingUtilities.isEventDispatchThread()) swingCode.run(); else SwingUtilities.invokeAndWait(swingCode); } catch (Exception e) { e.printStackTrace(); } } }
From source file:ddf.test.itests.catalog.TestCatalogValidation.java
/** * Setting configurations is performed asynchronously and there is no way to check if the * configured bean has received a configuration update. This method provides a best effort * workaround by retrying the test/assertions with a slight delay in between tries in an attempt * to let the configuration thread catch up. The Runnable.run() method will be called in each * attempt and all exceptions including AssertionErrors will be treated as a failed run and * retried.// ww w . j av a2 s . c om * * @param runnable */ private void testWithRetry(Runnable runnable) { with().pollInterval(1, SECONDS).await().atMost(30, SECONDS).ignoreExceptions().until(() -> { runnable.run(); return true; }); }
From source file:jetbrains.exodus.env.EnvironmentImpl.java
void runTransactionSafeTasks() { List<Runnable> tasksToRun = null; final long oldestTxnRoot = getOldestTxnRootAddress(); synchronized (txnSafeTasks) { while (true) { if (!txnSafeTasks.isEmpty()) { final RunnableWithTxnRoot r = txnSafeTasks.getFirst(); if (r.txnRoot < oldestTxnRoot) { txnSafeTasks.removeFirst(); if (tasksToRun == null) { tasksToRun = new ArrayList<>(4); }/* w w w . j a v a 2s. co m*/ tasksToRun.add(r.runnable); continue; } } break; } } if (tasksToRun != null) { for (final Runnable task : tasksToRun) { task.run(); } } }
From source file:com.haulmont.cuba.desktop.App.java
protected void recursiveClosingFrames(final Iterator<TopLevelFrame> it, final Runnable onSuccess) { final TopLevelFrame frame = it.next(); frame.getWindowManager().checkModificationsAndCloseAll(() -> { if (!it.hasNext()) { onSuccess.run(); } else {/*from www.j a v a 2s .c om*/ frame.getWindowManager().dispose(); frame.dispose(); it.remove(); recursiveClosingFrames(it, onSuccess); } }, null); }
From source file:com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.java
protected void internalIncludeItem(T item, Runnable addToData) { backgroundWorker.checkUIAccess();//from w w w .jav a2 s . c o m checkStateBeforeAdd(); addToData.run(); attachListener(item); fireCollectionChanged(Operation.ADD, Collections.singletonList(item)); }
From source file:com.saysth.commons.quartz.SchedulerFactoryBean.java
public void stop(Runnable callback) throws SchedulingException { stop(); callback.run(); }
From source file:co.cask.cdap.internal.app.runtime.spark.SparkRuntimeService.java
@Override protected Executor executor() { // Always execute in new daemon thread. return new Executor() { @Override/*from www. j a va 2 s. c o m*/ public void execute(final Runnable runnable) { final Thread t = new Thread(new Runnable() { @Override public void run() { // note: this sets logging context on the thread level LoggingContextAccessor.setLoggingContext(context.getLoggingContext()); runnable.run(); } }); t.setDaemon(true); t.setName(getServiceName()); t.start(); } }; }
From source file:com.facebook.FacebookActivityTestCase.java
protected void runAndBlockOnUiThread(final int expectedSignals, final Runnable runnable) throws Throwable { final TestBlocker blocker = getTestBlocker(); runTestOnUiThread(new Runnable() { @Override//from w w w.java2 s .c o m public void run() { runnable.run(); blocker.signal(); } }); // We wait for the operation to complete; wait for as many other signals as we expect. blocker.waitForSignals(1 + expectedSignals); // Wait for the UI thread to become idle so any UI updates the runnable triggered have a chance // to finish before we return. getInstrumentation().waitForIdleSync(); }