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:info.raack.appliancelabeler.service.DefaultDataService.java
@Transactional public void runInTransaction(Runnable runnable) { runnable.run(); }
From source file:com.github.lothar.security.acl.elasticsearch.repository.CustomerRepositoryTest.java
private void doWithoutCustomerFilter(Runnable runnable) { QueryBuilder customerFilter = customerStrategy.uninstall(elasticSearchFeature); try {//from ww w .j a v a 2 s .c o m runnable.run(); } finally { customerStrategy.install(elasticSearchFeature, customerFilter); } }
From source file:it.organization.OrganizationTest.java
private void expect403HttpError(Runnable runnable) { try {//from w w w.j a va 2 s.co m runnable.run(); fail("Ws call should have failed"); } catch (HttpException e) { assertThat(e.code()).isEqualTo(403); } }
From source file:it.organization.OrganizationTest.java
private void expect404HttpError(Runnable runnable) { try {/*w ww .j a va 2 s. c o m*/ runnable.run(); fail("Ws call should have failed"); } catch (HttpException e) { assertThat(e.code()).isEqualTo(404); } }
From source file:admin.jmx.BatchMBeanExporter.java
public final void stop(Runnable callback) { this.lifecycleLock.lock(); try {/*from w w w . ja v a2s . c o m*/ this.stop(); callback.run(); } finally { this.lifecycleLock.unlock(); } }
From source file:tech.sirwellington.alchemy.http.AlchemyMachineImplTest.java
@Test public void testExecuteAsyncWhenOnSuccessFails() { doThrow(new RuntimeException()).when(onSuccess).processResponse(pojo); instance.executeAsync(request, responseClass, onSuccess, onFailure); verify(executorService).submit(taskCaptor.capture()); Runnable task = taskCaptor.getValue(); assertThat(task, notNullValue());/* w ww.ja v a2 s . c om*/ task.run(); verify(onFailure).handleError(any()); }
From source file:SingleThreadRequestExecutor.java
public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command, long initialDelay, long period, TimeUnit unit) {/* w w w. j ava 2s . com*/ return executor.scheduleAtFixedRate(new Runnable() { @Override public void run() { try { command.run(); } catch (Throwable e) { // This normally bad code of catch on Exception is here for a *reason*. // Future *eats* all exceptions *silently*. This clause at least allows // the exception to emit noise for debugging. This is particularly pernicious // if you have something like a NullPointerException e.printStackTrace(); throw new RuntimeException(e); } } }, initialDelay, period, unit); }
From source file:tech.sirwellington.alchemy.http.AlchemyMachineImplTest.java
@Repeat(200) @Test//w w w .j a v a 2s . com public void testExecuteAsync() throws Exception { instance.executeAsync(request, responseClass, onSuccess, onFailure); verify(executorService).submit(taskCaptor.capture()); Runnable task = taskCaptor.getValue(); assertThat(task, notNullValue()); task.run(); verify(onSuccess).processResponse(pojo); }
From source file:SingleThreadRequestExecutor.java
public ScheduledFuture<?> scheduleWithFixedDelay(final Runnable command, long initialDelay, long delay, TimeUnit unit) {//from w w w. ja v a2s .com return executor.scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { command.run(); } catch (Throwable e) { // This normally bad code of catch on Exception is here for a *reason*. // Future *eats* all exceptions *silently*. This clause at least allows // the exception to emit noise for debugging. This is particularly pernicious // if you have something like a NullPointerException e.printStackTrace(); throw new RuntimeException(e); } } }, initialDelay, delay, unit); }
From source file:tech.sirwellington.alchemy.http.AlchemyMachineImplTest.java
@Test public void testExecuteAsyncWhenRuntimeExceptionHappens() { when(verb.execute(apacheClient, request)).thenThrow(new RuntimeException()); instance.executeAsync(request, responseClass, onSuccess, onFailure); verify(executorService).submit(taskCaptor.capture()); Runnable task = taskCaptor.getValue(); assertThat(task, notNullValue());/* ww w.jav a 2 s .co m*/ task.run(); verify(onFailure).handleError(any()); }