@Test public void whenParseTextWithJoinThenResultAmountOfWordsAndSpaces() { SpaceCalculator sp = new SpaceCalculator(); try { sp.parse("sdfsd sdfsdf sdfsdf sdfsdf", true); } catch (InterruptedException ie) { ie.printStackTrace(); } }
public void parse(String text, boolean pause) throws InterruptedException { System.out.println("White space calculator"); final ExecutorService executor = Executors.newFixedThreadPool(2); executor.submit(wordCountThread(text)); executor.submit(spaceCountThread(text)); if (pause && !executor.awaitTermination(1, TimeUnit.SECONDS)) { executor.shutdownNow(); } System.out.println("Finish"); }
SpaceCalculator { public void parse(String text, boolean pause) throws InterruptedException { System.out.println("White space calculator"); final ExecutorService executor = Executors.newFixedThreadPool(2); executor.submit(wordCountThread(text)); executor.submit(spaceCountThread(text)); if (pause && !executor.awaitTermination(1, TimeUnit.SECONDS)) { executor.shutdownNow(); } System.out.println("Finish"); } }
SpaceCalculator { public void parse(String text, boolean pause) throws InterruptedException { System.out.println("White space calculator"); final ExecutorService executor = Executors.newFixedThreadPool(2); executor.submit(wordCountThread(text)); executor.submit(spaceCountThread(text)); if (pause && !executor.awaitTermination(1, TimeUnit.SECONDS)) { executor.shutdownNow(); } System.out.println("Finish"); }  }
SpaceCalculator { public void parse(String text, boolean pause) throws InterruptedException { System.out.println("White space calculator"); final ExecutorService executor = Executors.newFixedThreadPool(2); executor.submit(wordCountThread(text)); executor.submit(spaceCountThread(text)); if (pause && !executor.awaitTermination(1, TimeUnit.SECONDS)) { executor.shutdownNow(); } System.out.println("Finish"); }  void parse(String text, boolean pause); }
SpaceCalculator { public void parse(String text, boolean pause) throws InterruptedException { System.out.println("White space calculator"); final ExecutorService executor = Executors.newFixedThreadPool(2); executor.submit(wordCountThread(text)); executor.submit(spaceCountThread(text)); if (pause && !executor.awaitTermination(1, TimeUnit.SECONDS)) { executor.shutdownNow(); } System.out.println("Finish"); }  void parse(String text, boolean pause);  }