### Question:
DynamicParallelOmegaOracle extends AbstractDynamicBatchProcessor<OmegaQuery<I, D>, OmegaMembershipOracle<S, I, D>> implements ParallelOmegaOracle<S, I, D> { @Override public void processQueries(Collection<? extends OmegaQuery<I, D>> omegaQueries) { processBatch(omegaQueries); } DynamicParallelOmegaOracle(Supplier<? extends OmegaMembershipOracle<S, I, D>> oracleSupplier,
                                      @NonNegative int batchSize,
                                      ExecutorService executor); @Override void processQueries(Collection<? extends OmegaQuery<I, D>> omegaQueries); @Override MembershipOracle<I, D> getMembershipOracle(); @Override boolean isSameState(Word<I> w1, S s1, Word<I> w2, S s2);  }### Answer:
@Test(dataProvider = "policies", dataProviderClass = Utils.class, timeOut = 2000) public void testThreadCreation(PoolPolicy poolPolicy) { final List<AnswerOnceQuery<Void>> queries = createQueries(10); final int expectedThreads = queries.size(); final CountDownLatch latch = new CountDownLatch(expectedThreads); final NullOracle[] oracles = new NullOracle[expectedThreads]; for (int i = 0; i < expectedThreads; i++) { oracles[i] = new NullOracle() { @Override public void processQueries(Collection<? extends OmegaQuery<Void, Void>> queries) { try { latch.countDown(); latch.await(); } catch (InterruptedException e) { throw new IllegalStateException(e); } super.processQueries(queries); } }; } final ParallelOmegaOracle<?, Void, Void> oracle = ParallelOracleBuilders.newDynamicParallelOmegaOracle(oracles[0], Arrays.copyOfRange(oracles, 1, oracles.length)) .withBatchSize(1) .withPoolSize(oracles.length) .withPoolPolicy(poolPolicy) .create(); try { oracle.processQueries(queries); } finally { oracle.shutdown(); } }
@Test(dataProvider = "policies", dataProviderClass = Utils.class, timeOut = 2000) public void testThreadScheduling(PoolPolicy poolPolicy) { final List<AnswerOnceQuery<Void>> queries = createQueries(10); final CountDownLatch latch = new CountDownLatch(queries.size() - 1); final NullOracle awaitingOracle = new NullOracle() { @Override public void processQueries(Collection<? extends OmegaQuery<Void, Void>> queries) { try { latch.await(); } catch (InterruptedException e) { throw new IllegalStateException(e); } super.processQueries(queries); } }; final NullOracle countDownOracle = new NullOracle() { @Override public void processQueries(Collection<? extends OmegaQuery<Void, Void>> queries) { latch.countDown(); super.processQueries(queries); } }; final ParallelOmegaOracle<?, Void, Void> oracle = ParallelOracleBuilders.newDynamicParallelOmegaOracle(awaitingOracle, countDownOracle) .withPoolSize(2) .withPoolPolicy(poolPolicy) .create(); try { oracle.processQueries(queries); } finally { oracle.shutdown(); } }