本文整理汇总了Java中co.paralleluniverse.strands.Strand.currentStrand方法的典型用法代码示例。如果您正苦于以下问题:Java Strand.currentStrand方法的具体用法?Java Strand.currentStrand怎么用?Java Strand.currentStrand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类co.paralleluniverse.strands.Strand
的用法示例。
在下文中一共展示了Strand.currentStrand方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
import co.paralleluniverse.strands.Strand; //导入方法依赖的package包/类
@Override
public void register() {
final Strand currentStrand = Strand.currentStrand();
if (!casWaiter(null, currentStrand)){
throw new IllegalMonitorStateException("attempt by " + currentStrand + " but owned by " + waiter);
}
}
示例2: unregister
import co.paralleluniverse.strands.Strand; //导入方法依赖的package包/类
@Override
public void unregister() {
if (waiter != Strand.currentStrand()){
throw new IllegalMonitorStateException("attempt by " + Strand.currentStrand() + " but owned by " + waiter);
}
waiter = null;
}
示例3: await
import co.paralleluniverse.strands.Strand; //导入方法依赖的package包/类
public void await() throws SuspendExecution {
waiter = Strand.currentStrand();
while (running.get() > 0) {
Strand.park();
}
}
示例4: currentStrand
import co.paralleluniverse.strands.Strand; //导入方法依赖的package包/类
/**
* Returns the current strand.
* This method will return a strand representing the fiber calling this method, or the current thread if this method is not
* called within a fiber.
*
* @return A strand representing the current fiber or thread
*/
public static Strand currentStrand() {
return Strand.currentStrand();
}