Source:
public void test() throws Exception { try (AccumuloClient client = getAccumuloClient()) { int batches = 12, batchSize = 8; String[] tableNames = getUniqueNames(batches * batchSize); for (String tableName : tableNames) { client.tableOperations().create(tableName); } final SortedSet<Text> splits = new TreeSet<>(); for (byte i = 0; i < 100; i++) { splits.add(new Text(new byte[] {0, 0, i})); } List<Future<?>> results = new ArrayList<>(); List<Runnable> tasks = new ArrayList<>(); SimpleThreadPool es = new SimpleThreadPool(batchSize * 2, "concurrent-api-requests"); for (String tableName : tableNames) { final String finalName = tableName; tasks.add(new Runnable() { @Override public void run() { try { client.tableOperations().addSplits(finalName, splits); } catch (TableNotFoundException ex) { } catch (Exception ex) { throw new RuntimeException(finalName, ex); } } }); tasks.add(new Runnable() { @Override public void run() { try { UtilWaitThread.sleep(500); client.tableOperations().delete(finalName); } catch (Exception ex) { throw new RuntimeException(ex); } } }); } Iterator<Runnable> itr = tasks.iterator(); for (int batch = 0; batch < batches; batch++) { for (int i = 0; i < batchSize; i++) { Future<?> f = es.submit(itr.next()); results.add(f); f = es.submit(itr.next()); results.add(f); } for (Future<?> f : results) { f.get(); } results.clear(); } List<Runnable> queued = es.shutdownNow(); assertTrue("Had more tasks to run", queued.isEmpty()); assertFalse("Had more tasks that needed to be submitted", itr.hasNext()); for (String tableName : tableNames) { assertFalse(client.tableOperations().exists(tableName)); } client.close(); } }

Target:
public void test() throws Exception { try (AccumuloClient client = getAccumuloClient()) { int batches = 12, batchSize = 8; String[] tableNames = getUniqueNames(batches * batchSize); for (String tableName : tableNames) { client.tableOperations().create(tableName); } final SortedSet<Text> splits = new TreeSet<>(); for (byte i = 0; i < 100; i++) { splits.add(new Text(new byte[] {0, 0, i})); } List<Future<?>> results = new ArrayList<>(); List<Runnable> tasks = new ArrayList<>(); SimpleThreadPool es = new SimpleThreadPool(batchSize * 2, "concurrent-api-requests"); for (String tableName : tableNames) { final String finalName = tableName; tasks.add(new Runnable() { @Override public void run() { try { client.tableOperations().addSplits(finalName, splits); } catch (TableNotFoundException ex) { } catch (Exception ex) { throw new RuntimeException(finalName, ex); } } }); tasks.add(new Runnable() { @Override public void run() { try { UtilWaitThread.sleep(500); client.tableOperations().delete(finalName); } catch (Exception ex) { throw new RuntimeException(ex); } } }); } Iterator<Runnable> itr = tasks.iterator(); for (int batch = 0; batch < batches; batch++) { for (int i = 0; i < batchSize; i++) { Future<?> f = es.submit(itr.next()); results.add(f); f = es.submit(itr.next()); results.add(f); } for (Future<?> f : results) { f.get(); } results.clear(); } List<Runnable> queued = es.shutdownNow(); assertTrue("Had more tasks to run", queued.isEmpty()); assertFalse("Had more tasks that needed to be submitted", itr.hasNext()); for (String tableName : tableNames) { assertFalse(client.tableOperations().exists(tableName)); } } }