本文整理了Java中java.util.concurrent.FutureTask.run()
方法的一些代码示例,展示了FutureTask.run()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FutureTask.run()
方法的具体详情如下:
包路径:java.util.concurrent.FutureTask
类名称:FutureTask
方法名:run
[英]Sets this Future to the result of its computation unless it has been cancelled.
[中]将此未来设置为其计算结果,除非已取消。
代码示例来源:origin: robolectric/robolectric
@Override
public void run() {
future.run();
}
});
代码示例来源:origin: apache/geode
@Override
public void run() {
if (periodic) {
super.runAndReset();
} else {
super.run();
}
}
代码示例来源:origin: robolectric/robolectric
@Override
public void run() {
future.run();
}
});
代码示例来源:origin: robolectric/robolectric
@Override
public void run() {
futureTask.run();
runnables.remove(this);
}
};
代码示例来源:origin: google/guava
@Override
public void run() {
task.run();
}
});
代码示例来源:origin: yanzhenjie/NoHttp
@Override
public void run() {
if (mLock == null) throw new IllegalStateException("The lock is null.");
synchronized (mLock) {
super.run();
mLock.notify();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Long> createPublisher(final long elements) {
FutureTask<Long> ft = new FutureTask<Long>(new Callable<Long>() {
@Override
public Long call() throws Exception {
return 1L;
}
});
ft.run();
return Flowable.fromFuture(ft);
}
代码示例来源:origin: yanzhenjie/NoHttp
@Override
public void run() {
if (mLock == null) throw new IllegalStateException("The lock is null.");
synchronized (mLock) {
mWorker.getRequest().start();
isStart = true;
mCallback.onStart(mWhat);
super.run();
mLock.notify();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureReturnsNull() {
FutureTask<Object> f = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
f.run();
Single.fromFuture(f).blockingGet();
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureTimedReturnsNull() {
FutureTask<Object> f = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
f.run();
Single.fromFuture(f, 1, TimeUnit.SECONDS).blockingGet();
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureTimedReturnsNull() {
FutureTask<Object> f = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
f.run();
Flowable.fromFuture(f, 1, TimeUnit.SECONDS).blockingLast();
}
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void fromFutureTimedReturnsNull() {
FutureTask<Object> f = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
f.run();
Observable.fromFuture(f, 1, TimeUnit.SECONDS).blockingLast();
}
代码示例来源:origin: neo4j/neo4j
@Test
void combinedFutureShouldGetResultsAfterAllComplete() throws Exception
{
FutureTask<String> task1 = new FutureTask<>( NOOP, "1" );
FutureTask<String> task2 = new FutureTask<>( NOOP, "2" );
FutureTask<String> task3 = new FutureTask<>( NOOP, "3" );
Future<List<String>> combined = Futures.combine( task1, task2, task3 );
assertThrows( TimeoutException.class, () -> combined.get( 10, TimeUnit.MILLISECONDS ) );
task3.run();
task2.run();
assertThrows( TimeoutException.class, () -> combined.get( 10, TimeUnit.MILLISECONDS ) );
task1.run();
List<String> result = combined.get();
assertThat( result, contains( "1", "2", "3" ) );
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void fromFutureReturnsNull() {
FutureTask<Object> f = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
f.run();
TestObserver<Object> to = new TestObserver<Object>();
Observable.fromFuture(f).subscribe(to);
to.assertNoValues();
to.assertNotComplete();
to.assertError(NullPointerException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void timedWait() {
FutureTask<Integer> ft = new FutureTask<Integer>(Functions.justCallable(1));
ft.run();
Maybe.fromFuture(ft, 1, TimeUnit.MILLISECONDS).test()
.awaitDone(5, TimeUnit.SECONDS)
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void fromFutureReturnsNull() {
FutureTask<Object> f = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
f.run();
TestSubscriber<Object> ts = new TestSubscriber<Object>();
Flowable.fromFuture(f).subscribe(ts);
ts.assertNoValues();
ts.assertNotComplete();
ts.assertError(NullPointerException.class);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void withTimeoutNoTimeout() {
FutureTask<Integer> task = new FutureTask<Integer>(new Runnable() {
@Override
public void run() {
}
}, 1);
task.run();
TestSubscriber<Integer> ts = TestSubscriber.create();
Flowable.fromFuture(task, 1, TimeUnit.SECONDS).subscribe(ts);
ts.assertValue(1);
ts.assertNoErrors();
ts.assertComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void normalDone() {
FutureTask<Object> ft = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, null);
FutureDisposable d = new FutureDisposable(ft, false);
assertFalse(d.isDisposed());
assertFalse(d.isDisposed());
ft.run();
assertTrue(d.isDisposed());
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void backpressure() {
TestSubscriber<Integer> ts = new TestSubscriber<Integer>(0);
FutureTask<Integer> f = new FutureTask<Integer>(new Runnable() {
@Override
public void run() {
}
}, 1);
f.run();
Flowable.fromFuture(f).subscribe(ts);
ts.assertNoValues();
ts.request(1);
ts.assertValue(1);
ts.assertNoErrors();
ts.assertComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void withTimeoutNoTimeoutScheduler() {
FutureTask<Integer> task = new FutureTask<Integer>(new Runnable() {
@Override
public void run() {
}
}, 1);
TestSubscriber<Integer> ts = TestSubscriber.create();
Flowable.fromFuture(task, Schedulers.computation()).subscribe(ts);
task.run();
ts.awaitTerminalEvent(5, TimeUnit.SECONDS);
ts.assertValue(1);
ts.assertNoErrors();
ts.assertComplete();
}
}
内容来源于网络,如有侵权,请联系作者删除!