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();
}
}