Here you can find the source of getUninterruptibly(Future
public static <T> T getUninterruptibly(Future<T> future)
//package com.java2s; //License from project: Apache License import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; public class Main { @SuppressWarnings("unchecked") public static <T, A extends Throwable, B extends Throwable, C extends Throwable, D extends Throwable> T getUninterruptibly( Future<T> future, Class<A> throwableA, Class<B> throwableB, Class<C> throwableC, Class<D> throwableD) throws A, B, C, D { while (true) { try { return future.get(); } catch (InterruptedException e) { //retry } catch (ExecutionException ee) { if (throwableA.isInstance(ee.getCause())) { throw (A) ee.getCause(); }/* w ww . ja va 2 s .c om*/ if (throwableB.isInstance(ee.getCause())) { throw (B) ee.getCause(); } if (throwableC.isInstance(ee.getCause())) { throw (C) ee.getCause(); } if (throwableD.isInstance(ee.getCause())) { throw (D) ee.getCause(); } throw new RuntimeException(ee.getCause()); } } } public static <T, A extends Throwable, B extends Throwable, C extends Throwable> T getUninterruptibly( Future<T> future, Class<A> throwableA, Class<B> throwableB, Class<C> throwableC) throws A, B, C { return getUninterruptibly(future, throwableA, throwableB, throwableC, RuntimeException.class); } public static <T, A extends Throwable, B extends Throwable> T getUninterruptibly( Future<T> future, Class<A> throwableA, Class<B> throwableB) throws A, B { return getUninterruptibly(future, throwableA, throwableB, RuntimeException.class, RuntimeException.class); } public static <T, A extends Throwable> T getUninterruptibly( Future<T> future, Class<A> throwableA) throws A { return getUninterruptibly(future, throwableA, RuntimeException.class, RuntimeException.class, RuntimeException.class); } public static <T> T getUninterruptibly(Future<T> future) { return getUninterruptibly(future, RuntimeException.class, RuntimeException.class, RuntimeException.class, RuntimeException.class); } }