Closed MiracleJoey closed 3 years ago
`public class Tester {
static Channel channel; public static void main(String[]args) throws InterruptedException, SuspendExecution { channel = startFiber(); channel.send( "1"); channel.send("2"); channel.send("3"); Thread.sleep(1000); channel.send("4"); channel.send("5"); System.out.println("out"); } public static Channel startFiber() { System.out.println("--------------------------------------------------1:" + Thread.currentThread().getName()); Channel<String> channel = ChannelFactory.newChannel(); new Fiber("fiber", () -> { System.out.println("--------------------------------------------------2:" + Thread.currentThread().getName()); BASIC_TURN: while (true) { System.out.println("--------------------------------------------------3:" + Thread.currentThread().getName()); select(receive(channel)); } }).start(); return channel; }
} `
--------------------------------------------------1:main --------------------------------------------------2:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 out --------------------------------------------------2:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13
why the second step is executed twice
The correct use of agents can solve this problem
-javaagent:quasar-core-0.8.0.jar
`public class Tester {
} `
--------------------------------------------------1:main --------------------------------------------------2:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 out --------------------------------------------------2:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13 --------------------------------------------------3:ForkJoinPool-default-fiber-pool-worker-13
why the second step is executed twice