本文整理汇总了Java中co.paralleluniverse.strands.Strand.park方法的典型用法代码示例。如果您正苦于以下问题:Java Strand.park方法的具体用法?Java Strand.park怎么用?Java Strand.park使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类co.paralleluniverse.strands.Strand
的用法示例。
在下文中一共展示了Strand.park方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: await
import co.paralleluniverse.strands.Strand; //导入方法依赖的package包/类
@Override
@Suspendable
public void await() throws InterruptedException {
try{
Strand.park(this);
}catch (SuspendExecution e){
throw new AssertionError();
}
if (Strand.interrupted()){
throw new InterruptedException();
}
}
示例2: execute
import co.paralleluniverse.strands.Strand; //导入方法依赖的package包/类
private boolean execute(Command command) throws InterruptedException, SuspendExecution {
this.nextCommand = command;
Strand.park();
return this.lastCommandReturnValue;
}
示例3: await
import co.paralleluniverse.strands.Strand; //导入方法依赖的package包/类
public void await() throws SuspendExecution {
waiter = Strand.currentStrand();
while (running.get() > 0) {
Strand.park();
}
}
示例4: park
import co.paralleluniverse.strands.Strand; //导入方法依赖的package包/类
/**
* Disables the current strand for scheduling purposes unless the
* permit is available.
* <p>
* <p>
* If the permit is available then it is consumed and the call returns
* immediately; otherwise
* the current strand becomes disabled for scheduling
* purposes and lies dormant until one of three things happens:
* <p>
* <ul>
* <li>Some other strand invokes {@link #unpark unpark} with the
* current strand as the target; or
* <p>
* <li>Some other strand interrupts
* the current strand; or
* <p>
* <li>The call spuriously (that is, for no reason) returns.
* </ul>
* <p>
* <p>
* This method does <em>not</em> report which of these caused the
* method to return. Callers should re-check the conditions which caused
* the strand to park in the first place. Callers may also determine,
* for example, the interrupt status of the strand upon return.
*/
public static void park() {
try {
Strand.park();
} catch (SuspendExecution e) {
throw RuntimeSuspendExecution.of(e);
}
}