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

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

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

FutureTask.awaitDone介绍

[英]Awaits completion or aborts on interrupt or timeout.
[中]等待完成或在中断或超时时中止。

代码示例

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get() throws InterruptedException, ExecutionException {
  int s = state;
  if (s <= COMPLETING)
    s = awaitDone(false, 0L);
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get(long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
  if (unit == null)
    throw new NullPointerException();
  int s = state;
  if (s <= COMPLETING &&
    (s = awaitDone(true, unit.toNanos(timeout))) <= COMPLETING)
    throw new TimeoutException();
  return report(s);
}

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

"main" #1 prio=5 os_prio=0 tid=0x000000000273b000 nid=0x2b24 waiting on condition [0x0000000002abf000]
 java.lang.Thread.State: TIMED_WAITING (parking)
   at sun.misc.Unsafe.park(Native Method)
   - parking to wait for  <0x0000000781973910> (a java.util.concurrent.FutureTask)
   at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
   at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:426)
   at java.util.concurrent.FutureTask.get(FutureTask.java:204)
   at Future.main(Future.java:19)

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

"pool-1-thread-1" #9 prio=5 os_prio=0 tid=0x00007ff50811c000 nid=0x5a5c waiting on condition [0x00007ff4e7365000]
  java.lang.Thread.State: TIMED_WAITING (sleeping)
  at java.lang.Thread.sleep(Native Method)
  at java.lang.Thread.sleep(Thread.java:340)
  at java.util.concurrent.TimeUnit.sleep(TimeUnit.java:386)
  at concurrent.Future$1.call(Future.java:19)
  at concurrent.Future$1.call(Future.java:15)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)

"main" #1 prio=5 os_prio=0 tid=0x00007ff50800a000 nid=0x5a4d waiting on condition [0x00007ff50e314000]
  java.lang.Thread.State: TIMED_WAITING (parking)
  at sun.misc.Unsafe.park(Native Method)
  - parking to wait for  <0x00000000ec03dda8> (a java.util.concurrent.FutureTask)
  at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
  at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:426)
  at java.util.concurrent.FutureTask.get(FutureTask.java:204)
  at concurrent.Future.main(Future.java:36)

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get() throws InterruptedException, ExecutionException {
  int s = state;
  if (s <= COMPLETING)
    s = awaitDone(false, 0L);
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get(long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
  if (unit == null)
    throw new NullPointerException();
  int s = state;
  if (s <= COMPLETING &&
    (s = awaitDone(true, unit.toNanos(timeout))) <= COMPLETING)
    throw new TimeoutException();
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get() throws InterruptedException, ExecutionException {
  int s = state;
  if (s <= COMPLETING)
    s = awaitDone(false, 0L);
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get() throws InterruptedException, ExecutionException {
  int s = state;
  if (s <= COMPLETING)
    s = awaitDone(false, 0L);
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get() throws InterruptedException, ExecutionException {
  int s = state;
  if (s <= COMPLETING)
    s = awaitDone(false, 0L);
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get() throws InterruptedException, ExecutionException {
  int s = state;
  if (s <= COMPLETING)
    s = awaitDone(false, 0L);
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get() throws InterruptedException, ExecutionException {
  int s = state;
  if (s <= COMPLETING)
    s = awaitDone(false, 0L);
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get(long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
  if (unit == null)
    throw new NullPointerException();
  int s = state;
  if (s <= COMPLETING &&
    (s = awaitDone(true, unit.toNanos(timeout))) <= COMPLETING)
    throw new TimeoutException();
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get(long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
  if (unit == null)
    throw new NullPointerException();
  int s = state;
  if (s <= COMPLETING &&
    (s = awaitDone(true, unit.toNanos(timeout))) <= COMPLETING)
    throw new TimeoutException();
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get(long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
  if (unit == null)
    throw new NullPointerException();
  int s = state;
  if (s <= COMPLETING &&
    (s = awaitDone(true, unit.toNanos(timeout))) <= COMPLETING)
    throw new TimeoutException();
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get(long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
  if (unit == null)
    throw new NullPointerException();
  int s = state;
  if (s <= COMPLETING &&
    (s = awaitDone(true, unit.toNanos(timeout))) <= COMPLETING)
    throw new TimeoutException();
  return report(s);
}

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

/**
 * @throws CancellationException {@inheritDoc}
 */
public V get(long timeout, TimeUnit unit)
  throws InterruptedException, ExecutionException, TimeoutException {
  if (unit == null)
    throw new NullPointerException();
  int s = state;
  if (s <= COMPLETING &&
    (s = awaitDone(true, unit.toNanos(timeout))) <= COMPLETING)
    throw new TimeoutException();
  return report(s);
}

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

Interrupted exception:
java.lang.InterruptedException
    at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:400)
    at java.util.concurrent.FutureTask.get(FutureTask.java:199)
    at ExceptionDemo.main(ExceptionDemo.java:20)

相关文章