Package pt.ul.jarmus.deadlocks.skip

Source Code of pt.ul.jarmus.deadlocks.skip.FjSelf1

package pt.ul.jarmus.deadlocks.skip;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.atomic.AtomicReference;

public class FjSelf1 {
  public static void main(String[] args) throws InterruptedException, ExecutionException {
    final AtomicReference<ForkJoinTask<?>> cell = new AtomicReference<>();
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        try {
          cell.get().join();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    };
    ForkJoinTask<?> t1 = ForkJoinTask.adapt(runnable);
    cell.set(t1);
    ForkJoinPool pool = new ForkJoinPool();
    pool.submit(t1);
    t1.get();
  }
}
TOP

Related Classes of pt.ul.jarmus.deadlocks.skip.FjSelf1

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.