diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishTest.java b/core-java-concurrency/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishTest.java index 17b71aa35b..7e2bf590fd 100644 --- a/core-java-concurrency/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishTest.java +++ b/core-java-concurrency/src/test/java/com/baeldung/concurrent/executorservice/WaitingForThreadsToFinishTest.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.concurrent.*; import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.fail; public class WaitingForThreadsToFinishTest { @@ -40,16 +39,13 @@ public class WaitingForThreadsToFinishTest { CountDownLatch latch = new CountDownLatch(2); for (int i = 0; i < 2; i++) { - WORKER_THREAD_POOL.submit(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(1000); - latch.countDown(); - } catch (InterruptedException e) { - e.printStackTrace(); - Thread.currentThread().interrupt(); - } + WORKER_THREAD_POOL.submit(() -> { + try { + Thread.sleep(1000); + latch.countDown(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); } }); } @@ -83,13 +79,9 @@ public class WaitingForThreadsToFinishTest { awaitTerminationAfterShutdown(WORKER_THREAD_POOL); try { - WORKER_THREAD_POOL.submit(new Callable() { - @Override - public String call() throws Exception { - fail("This thread should have been rejected !"); - Thread.sleep(1000000); - return null; - } + WORKER_THREAD_POOL.submit((Callable) () -> { + Thread.sleep(1000000); + return null; }); } catch (RejectedExecutionException ex) { //