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:CachedThread.java
public void run() { try {/*from w ww . ja va 2s.c o m*/ while (true) { // Wait for a runner: Runnable torun = waitForRunner(); // If runner, run: if (torun != null) torun.run(); // If dead, stop if (!alive) break; } } finally { cache.isDead(this); } }
From source file:com.zavakid.mushroom.impl.TestSinkQueue.java
/** * Test the consumeAll method/* w w w . j a va 2s.co m*/ * * @throws Exception */ @Test public void testConsumeAll() throws Exception { final int capacity = 64; // arbitrary final SinkQueue<Integer> q = new SinkQueue<Integer>(capacity); for (int i = 0; i < capacity; ++i) { assertTrue("should enqueue", q.enqueue(i)); } assertTrue("should not enqueue", !q.enqueue(capacity)); final Runnable trigger = mock(Runnable.class); q.consumeAll(new Consumer<Integer>() { private int expected = 0; public void consume(Integer e) { assertEquals("element", expected++, (int) e); trigger.run(); } }); verify(trigger, times(capacity)).run(); }
From source file:com.turbospaces.spaces.SpaceReceiveAdapter.java
private void sendResponseBackAfterExecution(final MethodCall methodCall, final Runnable task, final Address address, final ObjectBuffer objectBuffer) throws RemoteConnectFailureException { try {/*from w w w. j a va 2 s .c o m*/ task.run(); } catch (RuntimeException ex) { methodCall.setException(ex); logger.error(ex.getMessage(), ex); Throwables.propagate(ex); } finally { JChannel jChannel = jSpace.getSpaceConfiguration().getJChannel(); Message messageBack = new Message(); messageBack.setBuffer(objectBuffer.writeClassAndObject(methodCall)); messageBack.setDest(address); messageBack.setSrc(jChannel.getAddress()); try { jChannel.send(messageBack); } catch (Exception e) { logger.error(e.getMessage(), e); throw new RemoteConnectFailureException("unable to send response back to " + address, e); } } }
From source file:org.quantumbadger.redreader.activities.AlbumListingActivity.java
private void revertToWeb() { final Runnable r = new Runnable() { public void run() { if (!mHaveReverted) { mHaveReverted = true;/* w w w . j a va 2 s. c o m*/ LinkHandler.onLinkClicked(AlbumListingActivity.this, mUrl, true); finish(); } } }; if (General.isThisUIThread()) { r.run(); } else { AndroidApi.UI_THREAD_HANDLER.post(r); } }
From source file:com.predic8.membrane.core.interceptor.apimanagement.ApiManagementConfiguration.java
private void notifyConfigChangeObservers() { for (Runnable runner : configChangeObservers) { runner.run(); } }
From source file:com.jdom.get.stuff.done.android.AndroidApplicationContextFactory.java
public void displayYesNoConfirmation(String title, String msg, final Runnable yesAction, final Runnable noAction) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { yesAction.run(); }//from w w w.j a va2s . c om }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { noAction.run(); } }).setMessage(msg).setTitle(title); builder.show(); }
From source file:org.opendatakit.briefcase.ui.settings.SettingsPanelForm.java
void onReloadCache(Runnable callback) { reloadCacheButton.addActionListener(__ -> callback.run()); }
From source file:com.evolveum.midpoint.web.application.AsyncWebProcessManagerImpl.java
@Override public void submit(@NotNull String processId, Runnable runnable) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); SecurityContextManager secManager = application.getSecurityContextManager(); submit(processId, new SecurityContextAwareCallable(secManager, auth) { @Override//from w w w . j a v a2s . c o m public Object callWithContextPrepared() throws Exception { runnable.run(); return null; } }); }
From source file:org.opendatakit.briefcase.ui.settings.SettingsPanelForm.java
void onCleanAllPullResumePoints(Runnable callback) { cleanAllPullResumePointsButton.addActionListener(__ -> callback.run()); }
From source file:com.example.administrator.newsdaily.model.httpclient.AsyncHttpResponseHandler.java
/** * Helper method to send runnable into local handler loop * * @param runnable runnable instance, can be null *///from w ww .java2s. co m protected void postRunnable(Runnable runnable) { if (runnable != null) { if (getUseSynchronousMode()) { // This response handler is synchronous, run on current thread runnable.run(); } else { // Otherwise, run on provided handler handler.post(runnable); } } }