### Question:
GuardedQueue { public synchronized Integer get() { while (sourceList.isEmpty()) { try { LOGGER.info("waiting"); wait(); } catch (InterruptedException e) { e.printStackTrace(); } } LOGGER.info("getting"); return sourceList.peek(); } GuardedQueue(); synchronized Integer get(); synchronized void put(Integer e);  }### Answer:
@Test public void testGet() { GuardedQueue g = new GuardedQueue(); ExecutorService executorService = Executors.newFixedThreadPool(2); executorService.submit(() -> value = g.get()); executorService.submit(() -> g.put(10)); executorService.shutdown(); try { executorService.awaitTermination(30, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } assertEquals(Integer.valueOf(10), value); }
@Test public void testGet() { var g = new GuardedQueue(); var executorService = Executors.newFixedThreadPool(2); executorService.submit(() -> value = g.get()); executorService.submit(() -> g.put(10)); executorService.shutdown(); try { executorService.awaitTermination(30, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } assertEquals(Integer.valueOf(10), value); }
@Test public void testGet() { GuardedQueue g = new GuardedQueue(); ExecutorService executorService = Executors.newFixedThreadPool(2); executorService.submit(() -> value = g.get()); executorService.submit(() -> g.put(Integer.valueOf(10))); executorService.shutdown(); try { executorService.awaitTermination(30, TimeUnit.SECONDS); } catch (InterruptedException e) { e.printStackTrace(); } assertEquals(Integer.valueOf(10), value); }