@Test(expected=IllegalStateException.class) public void testSetNumberOfThreadsZero() { ThreadsEngine.setNumberOfThreads(0); }
public static void setNumberOfThreads(int numThreads) { if (numThreads < 1) throw new IllegalStateException("Number of threads must be a positive integer."); if (threadPool.size() > numThreads) throw new IllegalStateException("You cannot set a numThreads smaller than the current size of the threads pool."); if (threadPool.size() < numThreads) { for (int i=threadPool.size(); i<numThreads; i++) { threadPool.add(Executors.newSingleThreadExecutor()); } } }
ThreadsEngine { public static void setNumberOfThreads(int numThreads) { if (numThreads < 1) throw new IllegalStateException("Number of threads must be a positive integer."); if (threadPool.size() > numThreads) throw new IllegalStateException("You cannot set a numThreads smaller than the current size of the threads pool."); if (threadPool.size() < numThreads) { for (int i=threadPool.size(); i<numThreads; i++) { threadPool.add(Executors.newSingleThreadExecutor()); } } } }
ThreadsEngine { public static void setNumberOfThreads(int numThreads) { if (numThreads < 1) throw new IllegalStateException("Number of threads must be a positive integer."); if (threadPool.size() > numThreads) throw new IllegalStateException("You cannot set a numThreads smaller than the current size of the threads pool."); if (threadPool.size() < numThreads) { for (int i=threadPool.size(); i<numThreads; i++) { threadPool.add(Executors.newSingleThreadExecutor()); } } }  }
ThreadsEngine { public static void setNumberOfThreads(int numThreads) { if (numThreads < 1) throw new IllegalStateException("Number of threads must be a positive integer."); if (threadPool.size() > numThreads) throw new IllegalStateException("You cannot set a numThreads smaller than the current size of the threads pool."); if (threadPool.size() < numThreads) { for (int i=threadPool.size(); i<numThreads; i++) { threadPool.add(Executors.newSingleThreadExecutor()); } } }  static void setNumberOfThreads(int numThreads); static int getNumberOfThreads(); static ExecutorService getThreadWithIndex(int index); static void submitTopology(Topology topology, int numThreads); static void clearThreadPool(); }
ThreadsEngine { public static void setNumberOfThreads(int numThreads) { if (numThreads < 1) throw new IllegalStateException("Number of threads must be a positive integer."); if (threadPool.size() > numThreads) throw new IllegalStateException("You cannot set a numThreads smaller than the current size of the threads pool."); if (threadPool.size() < numThreads) { for (int i=threadPool.size(); i<numThreads; i++) { threadPool.add(Executors.newSingleThreadExecutor()); } } }  static void setNumberOfThreads(int numThreads); static int getNumberOfThreads(); static ExecutorService getThreadWithIndex(int index); static void submitTopology(Topology topology, int numThreads); static void clearThreadPool();  }