本文整理汇总了Java中co.paralleluniverse.fibers.Fiber.join方法的典型用法代码示例。如果您正苦于以下问题:Java Fiber.join方法的具体用法?Java Fiber.join怎么用?Java Fiber.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类co.paralleluniverse.fibers.Fiber
的用法示例。
在下文中一共展示了Fiber.join方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDefaultSleep
import co.paralleluniverse.fibers.Fiber; //导入方法依赖的package包/类
@Test
public void testDefaultSleep() throws Exception {
final Script script = createScript("sleep(1000);", new HashMap<String, Object>());
final AtomicInteger counter = new AtomicInteger(0);
Fiber fiber = new Fiber(scheduler, new SuspendableRunnable() {
@Override
public void run() throws SuspendExecution, InterruptedException {
counter.incrementAndGet();
script.run();
counter.incrementAndGet();
}
});
fiber.start();
fiber.join();
Assert.assertEquals(counter.intValue(), 2);
}
示例2: testClosuresSleep
import co.paralleluniverse.fibers.Fiber; //导入方法依赖的package包/类
@Test
public void testClosuresSleep() throws Exception {
final SleepMethodSupport sleepMethodSupport = new SleepMethodSupport();
HashMap<String, Object> args = new HashMap<String, Object>() {
{
put("sleepMethodSupport", sleepMethodSupport);
put("_sleep", new MethodClosure(sleepMethodSupport, "_sleep"));
}
};
final Script script = createScript("sleep(1000);_sleep(1000);sleepMethodSupport._sleep(1000)", args);
final AtomicInteger counter = new AtomicInteger(0);
Fiber fiber = new Fiber(scheduler, new SuspendableRunnable() {
@Override
public void run() throws SuspendExecution, InterruptedException {
counter.incrementAndGet();
script.run();
counter.incrementAndGet();
}
});
fiber.start();
fiber.join();
Assert.assertEquals(counter.intValue(), 2);
}
示例3: selectMethodInstrumented
import co.paralleluniverse.fibers.Fiber; //导入方法依赖的package包/类
@Test
public void selectMethodInstrumented() throws Exception {
Assert.assertTrue(SuspendableHelper.isInstrumented(org.codehaus.groovy.vmplugin.v7.IndyInterface.class, "selectMethod"));
final Script script = createScript("sleep(1000);", new HashMap<String, Object>());
Fiber fiber = new Fiber(scheduler, new SuspendableRunnable() {
@Override
public void run() throws SuspendExecution, InterruptedException {
script.run();
}
});
fiber.start();
fiber.join();
}