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

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

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

FutureTask.done介绍

[英]Protected method invoked when this task transitions to state isDone (whether normally or via cancellation). The default implementation does nothing. Subclasses may override this method to invoke completion callbacks or perform bookkeeping. Note that you can query status inside the implementation of this method to determine whether this task has been cancelled.
[中]此任务转换为状态isDone(正常或通过取消)时调用的受保护方法。默认实现不执行任何操作。子类可以重写此方法以调用完成回调或执行簿记。请注意,您可以查询此方法实现内部的状态,以确定此任务是否已取消。

代码示例

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

/**
 * Removes and signals all waiting threads, invokes done(), and
 * nulls out callable.
 */
private void finishCompletion() {
  // assert state > COMPLETING;
  for (WaitNode q; (q = waiters) != null;) {
    if (UNSAFE.compareAndSwapObject(this, waitersOffset, q, null)) {
      for (;;) {
        Thread t = q.thread;
        if (t != null) {
          q.thread = null;
          LockSupport.unpark(t);
        }
        WaitNode next = q.next;
        if (next == null)
          break;
        q.next = null; // unlink to help gc
        q = next;
      }
      break;
    }
  }
  done();
  callable = null;        // to reduce footprint
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
  protected void done() {
    super.done();
    if (isCancelled()) {
      return;
    }

    try {
      get();
    } catch (ExecutionException ex) {
      Logger log = owner == null ? GlowServer.logger : owner.getLogger();
      log.log(Level.SEVERE, "Error while executing " + this, ex.getCause());
    } catch (InterruptedException e) {
      // Task is already done, see the fact that we're in done() method
    }
  }
}

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

protected void set(V value) {
  if (!_done) {
    _value = value;
    _done = true;
    done();
  }
}

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

@Override
  protected void done() {
    super.done();
    synchronized (this) {
      this.notifyAll();
    }
  }
};

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

protected void setException(Throwable t) {
  if (t == null)
    throw new IllegalArgumentException();
  if (!_done) {
    _throwable = t;
    _done = true;
    done();
  }
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

@Override
  protected void done() {
    super.done();
    synchronized (this) {
      this.notifyAll();
    }
  }
};

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

@Override
protected void done() {
  super.done();
  
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      try {
        JXImagePanel.this.setImage(get());
      } catch (InterruptedException e) {
        // ignore - canceled image load
      } catch (ExecutionException e) {
        LOG.log(Level.WARNING, "", e);
      }
    }
  });
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@Override
protected void done() {
  super.done();
  
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      try {
        JXImagePanel.this.setImage(get());
      } catch (InterruptedException e) {
        // ignore - canceled image load
      } catch (ExecutionException e) {
        LOG.log(Level.WARNING, "", e);
      }
    }
  });
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
protected void done() {
  super.done();
  
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      try {
        JXImagePanel.this.setImage(get());
      } catch (InterruptedException e) {
        // ignore - canceled image load
      } catch (ExecutionException e) {
        LOG.log(Level.WARNING, "", e);
      }
    }
  });
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

@Override
protected void done() {
  super.done();
  
  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      try {
        JXImagePanel.this.setImage(get());
      } catch (InterruptedException e) {
        // ignore - canceled image load
      } catch (ExecutionException e) {
        LOG.log(Level.WARNING, "", e);
      }
    }
  });
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

@Override
protected void done() {
  super.done();
  
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      try {
        JXImagePanel.this.setImage(get());
      } catch (InterruptedException e) {
        // ignore - canceled image load
      } catch (ExecutionException e) {
        LOG.log(Level.WARNING, "", e);
      }
    }
  });
}

代码示例来源:origin: net.sf.kerner-utils/kerner-utils

@Override
protected synchronized void done() {
  super.done();
  for (final ListenerDone listener : listeners) {
    listener.isDone(this);
  }
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Removes and signals all waiting threads, invokes done(), and
 * nulls out callable.
 */
private void finishCompletion() {
  // assert state > COMPLETING;
  for (WaitNode q; (q = waiters) != null;) {
    if (UNSAFE.compareAndSwapObject(this, waitersOffset, q, null)) {
      for (;;) {
        Thread t = q.thread;
        if (t != null) {
          q.thread = null;
          LockSupport.unpark(t);
        }
        WaitNode next = q.next;
        if (next == null)
          break;
        q.next = null; // unlink to help gc
        q = next;
      }
      break;
    }
  }
  done();
  callable = null;        // to reduce footprint
}

代码示例来源:origin: ibinti/bugvm

/**
 * Removes and signals all waiting threads, invokes done(), and
 * nulls out callable.
 */
private void finishCompletion() {
  // assert state > COMPLETING;
  for (WaitNode q; (q = waiters) != null;) {
    if (UNSAFE.compareAndSwapObject(this, waitersOffset, q, null)) {
      for (;;) {
        Thread t = q.thread;
        if (t != null) {
          q.thread = null;
          LockSupport.unpark(t);
        }
        WaitNode next = q.next;
        if (next == null)
          break;
        q.next = null; // unlink to help gc
        q = next;
      }
      break;
    }
  }
  done();
  callable = null;        // to reduce footprint
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Removes and signals all waiting threads, invokes done(), and
 * nulls out callable.
 */
private void finishCompletion() {
  // assert state > COMPLETING;
  for (WaitNode q; (q = waiters) != null;) {
    if (UNSAFE.compareAndSwapObject(this, waitersOffset, q, null)) {
      for (;;) {
        Thread t = q.thread;
        if (t != null) {
          q.thread = null;
          LockSupport.unpark(t);
        }
        WaitNode next = q.next;
        if (next == null)
          break;
        q.next = null; // unlink to help gc
        q = next;
      }
      break;
    }
  }
  done();
  callable = null;        // to reduce footprint
}

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

/**
 * Removes and signals all waiting threads, invokes done(), and
 * nulls out callable.
 */
private void finishCompletion() {
  // assert state > COMPLETING;
  for (WaitNode q; (q = waiters) != null;) {
    if (UNSAFE.compareAndSwapObject(this, waitersOffset, q, null)) {
      for (;;) {
        Thread t = q.thread;
        if (t != null) {
          q.thread = null;
          LockSupport.unpark(t);
        }
        WaitNode next = q.next;
        if (next == null)
          break;
        q.next = null; // unlink to help gc
        q = next;
      }
      break;
    }
  }
  done();
  callable = null;        // to reduce footprint
}

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

@Override
protected void done() {
  super.done();
  if (contextSwitched.get()) {
    PhaseInterceptorChain.setCurrentMessage(chain, null);
    message.remove(Message.THREAD_CONTEXT_SWITCHED);
  }
  chain.releaseChain();
}

代码示例来源:origin: org.apache.cxf/cxf-core

@Override
protected void done() {
  super.done();
  if (contextSwitched.get()) {
    PhaseInterceptorChain.setCurrentMessage(chain, null);
    message.remove(Message.THREAD_CONTEXT_SWITCHED);
  }
  chain.releaseChain();
}

代码示例来源:origin: feixiao/DesignPattern

@Override
 protected void done() {
  super.done();
  try {
   /*
    * called in context of background thread. There is other variant possible where result is
    * posted back and sits in the queue of caller thread which then picks it up for
    * processing. An example of such a system is Android OS, where the UI elements can only
    * be updated using UI thread. So result must be posted back in UI thread.
    */
   task.onPostCall(get());
  } catch (InterruptedException e) {
   // should not occur
  } catch (ExecutionException e) {
   task.onError(e.getCause());
  }
 }
});

代码示例来源:origin: org.glassfish/javax.enterprise.concurrent

@Override
protected void done() { 
  // for calling taskDone for cancelled tasks
  super.done();
  if (taskDoneCallback != null) {
    taskDoneCallback.taskDone(this);
  }
  if (taskListener != null && isCancelled()) {
    try {
      if (isContextualCallback) {
        setupContext();
      }
      taskListener.taskDone(this, 
          executor.getExecutorForTaskListener(),
          task,
          new CancellationException());
    }
    finally {
      if (isContextualCallback) {
        resetContext();
      }
    }
  }
}

相关文章