@Test public void test() { String[] args = {}; App.main(args); }
public static void main(String[] args) { final Inventory inventory = new Inventory(1000); ExecutorService executorService = Executors.newFixedThreadPool(3); for (int i = 0; i < 3; i++) { executorService.execute(() -> { while (inventory.addItem(new Item())) { } ; }); } executorService.shutdown(); try { executorService.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { LOGGER.error("Error waiting for ExecutorService shutdown"); } }
App { public static void main(String[] args) { final Inventory inventory = new Inventory(1000); ExecutorService executorService = Executors.newFixedThreadPool(3); for (int i = 0; i < 3; i++) { executorService.execute(() -> { while (inventory.addItem(new Item())) { } ; }); } executorService.shutdown(); try { executorService.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { LOGGER.error("Error waiting for ExecutorService shutdown"); } } }
App { public static void main(String[] args) { final Inventory inventory = new Inventory(1000); ExecutorService executorService = Executors.newFixedThreadPool(3); for (int i = 0; i < 3; i++) { executorService.execute(() -> { while (inventory.addItem(new Item())) { } ; }); } executorService.shutdown(); try { executorService.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { LOGGER.error("Error waiting for ExecutorService shutdown"); } }  }
App { public static void main(String[] args) { final Inventory inventory = new Inventory(1000); ExecutorService executorService = Executors.newFixedThreadPool(3); for (int i = 0; i < 3; i++) { executorService.execute(() -> { while (inventory.addItem(new Item())) { } ; }); } executorService.shutdown(); try { executorService.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { LOGGER.error("Error waiting for ExecutorService shutdown"); } }  static void main(String[] args); }
App { public static void main(String[] args) { final Inventory inventory = new Inventory(1000); ExecutorService executorService = Executors.newFixedThreadPool(3); for (int i = 0; i < 3; i++) { executorService.execute(() -> { while (inventory.addItem(new Item())) { } ; }); } executorService.shutdown(); try { executorService.awaitTermination(5, TimeUnit.SECONDS); } catch (InterruptedException e) { LOGGER.error("Error waiting for ExecutorService shutdown"); } }  static void main(String[] args);  }