I just want to implement an aync mehod in one thread, and the method may pack and unpack many times , but once I call pack at the 2nd time, it will re-call the full method twice, I just need it to run from laster park block,
it print :
Thread name:ForkJoinPool-default-fiber-pool-worker-5 run
Thread name:ForkJoinPool-default-fiber-pool-worker-5 before park
Thread name:ForkJoinPool-default-fiber-pool-worker-5 run
Thread name:ForkJoinPool-default-fiber-pool-worker-5 before park
Thread name:ForkJoinPool-default-fiber-pool-worker-5 ==== unparked
Thread name:ForkJoinPool-default-fiber-pool-worker-5 before park
I just want to implement an aync mehod in one thread, and the method may pack and unpack many times , but once I call pack at the 2nd time, it will re-call the full method twice, I just need it to run from laster park block,
public class SuspendTest implements SuspendableRunnable { public void run() throws SuspendExecution { System.out.println("Thread name:" + Thread.currentThread().getName() + " run"); System.out.println("Thread name:" + Thread.currentThread().getName() + " before park"); Strand.park(this.obj); System.out.println("Thread name:" + Thread.currentThread().getName() + " ==== unparked "); System.out.println("Thread name:" + Thread.currentThread().getName() + " before park"); Strand.park(this.obj); System.out.println("Thread name:" + Thread.currentThread().getName() + " ==== unparked "); } }
it print : Thread name:ForkJoinPool-default-fiber-pool-worker-5 run Thread name:ForkJoinPool-default-fiber-pool-worker-5 before park Thread name:ForkJoinPool-default-fiber-pool-worker-5 run Thread name:ForkJoinPool-default-fiber-pool-worker-5 before park Thread name:ForkJoinPool-default-fiber-pool-worker-5 ==== unparked Thread name:ForkJoinPool-default-fiber-pool-worker-5 before park