本文整理汇总了Java中java.util.concurrent.FutureTask.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java FutureTask.isCancelled方法的具体用法?Java FutureTask.isCancelled怎么用?Java FutureTask.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.FutureTask
的用法示例。
在下文中一共展示了FutureTask.isCancelled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterExecute
import java.util.concurrent.FutureTask; //导入方法依赖的package包/类
@Override
protected void afterExecute(Runnable task, Throwable exception) {
if (task instanceof FutureTask<?>) {
FutureTask<?> futureTask = (FutureTask<?>) task;
if (!futureTask.isCancelled()) {
try {
futureTask.get();
} catch (ExecutionException ee) {
exception = ee.getCause();
} catch (InterruptedException ie) {
exception = ie;
}
}
}
if (exception != null) {
LOG.error("Exception during execution of task in DeletionService",
exception);
}
}
示例2: drawContents
import java.util.concurrent.FutureTask; //导入方法依赖的package包/类
@Override
public void drawContents(TimeGraphTreeRender treeRender, TimeRange timeRange,
VerticalPosition vPos, @Nullable FutureTask<?> task) {
final long resolution = Math.max(1, Math.round(getWidget().getCurrentNanosPerPixel()));
final List<TimeGraphTreeElement> allTreeElements = treeRender.getAllTreeElements();
final int nbElements = allTreeElements.size();
final int entriesToPrefetch = getWidget().getDebugOptions().entryPadding.get();
final int topEntry = Math.max(0,
TimeGraphWidget.paneYPosToEntryListIndex(vPos.fTopPos, TimeGraphWidget.ENTRY_HEIGHT) - entriesToPrefetch);
final int bottomEntry = Math.min(nbElements,
TimeGraphWidget.paneYPosToEntryListIndex(vPos.fBottomPos, TimeGraphWidget.ENTRY_HEIGHT) + entriesToPrefetch);
LOGGER.finest(() -> "topEntry=" + topEntry +", bottomEntry=" + bottomEntry);
List<TimeGraphStateRender> stateRenders = allTreeElements.subList(topEntry, bottomEntry).stream()
.map(treeElem -> fStateProvider.getStateRender(treeElem, timeRange, resolution, task))
.collect(Collectors.toList());
if (task != null && task.isCancelled()) {
return;
}
Collection<StateRectangle> stateRectangles = prepareStateRectangles(stateRenders, topEntry);
Node statesLayerContents = prepareTimeGraphStatesContents(stateRectangles);
Node labelsLayerContents = prepareTimeGrahLabelsContents(stateRectangles, fWindowRange);
/*
* Go over all state rectangles, and bring the "multi-state"
* ones to the front, to be sure they show on top of the others.
* Note we cannot do the forEach() as part of the stream, that
* would throw a ConcurrentModificationException.
*/
((Group) statesLayerContents).getChildren().stream()
.map(node -> (StateRectangle) node)
.filter(rect -> (rect.getStateInterval().isMultiState()))
.collect(Collectors.toList())
.forEach(Node::toFront);
Platform.runLater(() -> {
getParentGroup().getChildren().clear();
getLabelGroup().getChildren().clear();
getParentGroup().getChildren().add(statesLayerContents);
getLabelGroup().getChildren().add(labelsLayerContents);
});
}
示例3: run
import java.util.concurrent.FutureTask; //导入方法依赖的package包/类
static <V> void run(FutureTask<V> task) {
boolean isCancelled = task.isCancelled();
task.run();
check(task.isDone());
equal(isCancelled, task.isCancelled());
}