/** * This method enables blocking Runnables to be used efficiently * with the common Java fork/join thread pool. */ public static void runInManagedBlock(final Runnable runnable) { // Create a helper object to encapsulate the runnable. final RunnableManagedBlock managedBlock = new RunnableManagedBlock(runnable); try { // Submit managedBlock to the common ForkJoin thread pool. ForkJoinPool.managedBlock(managedBlock); } catch (InterruptedException e) { throw new Error(e); } }