java.util.concurrent.FutureTask.set()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中java.util.concurrent.FutureTask.set()方法的一些代码示例,展示了FutureTask.set()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FutureTask.set()方法的具体详情如下:
包路径:java.util.concurrent.FutureTask
类名称:FutureTask
方法名:set

FutureTask.set介绍

[英]Sets the result of this future to the given value unless this future has already been set or has been cancelled.

This method is invoked internally by the #run method upon successful completion of the computation.
[中]将此未来的结果设置为给定值,除非已设置或已取消此未来。
成功完成计算后,#run方法在内部调用此方法。

代码示例

代码示例来源:origin: kairosdb/kairosdb

@Override
  public void set(Integer retries)
  {
    //Todo Calculate time to run and adjust number of threads
    /*if (full)
    {
    }*/
    super.set(retries);
  }
}

代码示例来源:origin: robovm/robovm

set(result);

代码示例来源:origin: apache/activemq

public void complete() {
  super.set(null);
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
protected void set(Bundle bundle) {
  // TODO: somehow a null is being set as the result of the Future. Log this
  // case to help debug where this is occurring. When this bug is fixed this
  // condition statement should be removed.
  if (bundle == null) {
    VLog.e("AccountManager", "the bundle must not be null", new Exception());
  }
  super.set(bundle);
}

代码示例来源:origin: mpusher/mpush

private void submit(Status status) {
  if (this.status.compareAndSet(Status.init, status)) {//防止重复调用
    boolean isTimeoutEnd = status == Status.timeout;//任务是否超时结束
    if (future != null && !isTimeoutEnd) {//是超时结束任务不用再取消一次
      future.cancel(true);//取消超时任务
    }
    this.timeLine.end();//结束时间流统计
    super.set(getResult());//设置同步调用的返回结果
    if (callback != null) {//回调callback
      if (isTimeoutEnd) {//超时结束时,当前线程已经是线程池里的线程,直接调用callback
        callback.onResult(getResult());
      } else {//非超时结束时,当前线程为Netty线程池,要异步执行callback
        mPushClient.getPushRequestBus().asyncCall(this);//会执行run方法
      }
    }
  }
  LOGGER.info("push request {} end, {}, {}, {}", status, userId, location, timeLine);
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

@Override
public void set(T t) {
  super.set(t);
}

代码示例来源:origin: hugegraph/hugegraph

@Override
protected void set(V v) {
  this.status(TaskStatus.SUCCESS);
  if (v != null) {
    this.result = v.toString();
  }
  super.set(v);
}

代码示例来源:origin: stackoverflow.com

public Bar getBar() {
  final BarPointer barPointer = new BarPointer().

  BarBuilder.buildNewBar(barPointer);

  return barPointer.get();
}

public class BarPointer extends FutureTask<Bar> implements BarListener {
  @Override
  public void onNewBar(Bar bar) {
    set(bar);
  }
}

代码示例来源:origin: com.carecon.fabric3/fabric3-binding-zeromq

@Override
public void set(byte[] s) {
  super.set(s);
}

代码示例来源:origin: org.codehaus.fabric3/fabric3-binding-zeromq

@Override
public void set(byte[] s) {
  super.set(s);
}

代码示例来源:origin: knightliao/common-utils

public void set(V v) {
    super.set(v);
  }
}

代码示例来源:origin: apache/activemq-artemis

protected void set(Object o) {
  super.set(o);
}

代码示例来源:origin: org.objectfabric/objectfabric-api

@Override
public void set(V value) {
  super.set(value);
}

代码示例来源:origin: jboss-fuse/fabric8

public void onSuccess(T result) {
  super.set(result);
}

代码示例来源:origin: com.liferay/com.liferay.petra.concurrent

@Override
public void set(T t) {
  super.set(t);
}

代码示例来源:origin: lexs/webimageloader

@Override
public void set(Bitmap v) {
  super.set(v);
}

代码示例来源:origin: bioinformatics-ua/dicoogle

@Override
protected void set(Type ret){
  super.set(ret);
  for(Runnable r : toRunWhenComplete){
    r.run();
  }
}

代码示例来源:origin: com.baidu.hugegraph/hugegraph-core

@Override
protected void set(V v) {
  this.status(TaskStatus.SUCCESS);
  if (v != null) {
    this.result = v.toString();
  }
  super.set(v);
}

代码示例来源:origin: darkskygit/VirtualApp

@Override
protected void set(Bundle bundle) {
  // TODO: somehow a null is being set as the result of the Future. Log this
  // case to help debug where this is occurring. When this bug is fixed this
  // condition statement should be removed.
  if (bundle == null) {
    VLog.e("AccountManager", "the bundle must not be null", new Exception());
  }
  super.set(bundle);
}

代码示例来源:origin: bzsome/VirtualApp-x326

@Override
protected void set(Bundle bundle) {
  // TODO: somehow a null is being set as the result of the Future. Log this
  // case to help debug where this is occurring. When this bug is fixed this
  // condition statement should be removed.
  if (bundle == null) {
    VLog.e("AccountManager", "the bundle must not be null", new Exception());
  }
  super.set(bundle);
}

相关文章