diff --git a/core-java-modules/core-java-concurrency-basic-2/README.md b/core-java-modules/core-java-concurrency-basic-2/README.md index 1dad941e57..af46046709 100644 --- a/core-java-modules/core-java-concurrency-basic-2/README.md +++ b/core-java-modules/core-java-concurrency-basic-2/README.md @@ -12,7 +12,6 @@ This module contains articles about basic Java concurrency - [Guide to AtomicMarkableReference](https://www.baeldung.com/java-atomicmarkablereference) - [Why are Local Variables Thread-Safe in Java](https://www.baeldung.com/java-local-variables-thread-safe) - [How to Stop Execution After a Certain Time in Java](https://www.baeldung.com/java-stop-execution-after-certain-time) -- [How to Handle InterruptedException in Java](https://www.baeldung.com/java-interrupted-exception) - [How to Get the Number of Threads in a Java Process](https://www.baeldung.com/java-get-number-of-threads) - [Set the Name of a Thread in Java](https://www.baeldung.com/java-set-thread-name) -- [[<-- Prev]](/core-java-modules/core-java-concurrency-basic) +- [[<-- Prev]](../core-java-concurrency-basic)[[Next -->]](../core-java-concurrency-basic-3) diff --git a/core-java-modules/core-java-concurrency-basic-2/src/main/resources/logback.xml b/core-java-modules/core-java-concurrency-basic-2/src/main/resources/logback.xml index 56af2d397e..7d900d8ea8 100644 --- a/core-java-modules/core-java-concurrency-basic-2/src/main/resources/logback.xml +++ b/core-java-modules/core-java-concurrency-basic-2/src/main/resources/logback.xml @@ -7,12 +7,6 @@ - - - - - - diff --git a/core-java-modules/core-java-concurrency-basic-3/README.md b/core-java-modules/core-java-concurrency-basic-3/README.md new file mode 100644 index 0000000000..477f37e00a --- /dev/null +++ b/core-java-modules/core-java-concurrency-basic-3/README.md @@ -0,0 +1,8 @@ +## Core Java Concurrency Basic + +This module contains articles about basic Java concurrency. + +### Relevant Articles: + +- [How to Handle InterruptedException in Java](https://www.baeldung.com/java-interrupted-exception) +- [[<-- Prev]](../core-java-concurrency-basic-2) diff --git a/core-java-modules/core-java-concurrency-basic-3/pom.xml b/core-java-modules/core-java-concurrency-basic-3/pom.xml new file mode 100644 index 0000000000..20615e3250 --- /dev/null +++ b/core-java-modules/core-java-concurrency-basic-3/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + core-java-concurrency-basic-3 + 0.1.0-SNAPSHOT + core-java-concurrency-basic-3 + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + + core-java-concurrency-basic-3 + + + src/main/resources + true + + + + + diff --git a/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/interrupt/CustomInterruptedException.java b/core-java-modules/core-java-concurrency-basic-3/src/main/java/com/baeldung/concurrent/interrupt/CustomInterruptedException.java similarity index 100% rename from core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/interrupt/CustomInterruptedException.java rename to core-java-modules/core-java-concurrency-basic-3/src/main/java/com/baeldung/concurrent/interrupt/CustomInterruptedException.java diff --git a/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/interrupt/InterruptExample.java b/core-java-modules/core-java-concurrency-basic-3/src/main/java/com/baeldung/concurrent/interrupt/InterruptExample.java similarity index 100% rename from core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/interrupt/InterruptExample.java rename to core-java-modules/core-java-concurrency-basic-3/src/main/java/com/baeldung/concurrent/interrupt/InterruptExample.java diff --git a/core-java-modules/core-java-concurrency-basic-3/src/main/resources/logback.xml b/core-java-modules/core-java-concurrency-basic-3/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-concurrency-basic-3/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-basic-2/src/test/java/com/baeldung/concurrent/interrupt/InterruptExampleUnitTest.java b/core-java-modules/core-java-concurrency-basic-3/src/test/java/com/baeldung/concurrent/interrupt/InterruptExampleUnitTest.java similarity index 81% rename from core-java-modules/core-java-concurrency-basic-2/src/test/java/com/baeldung/concurrent/interrupt/InterruptExampleUnitTest.java rename to core-java-modules/core-java-concurrency-basic-3/src/test/java/com/baeldung/concurrent/interrupt/InterruptExampleUnitTest.java index 1ea3f9aa9b..d11ac670f3 100644 --- a/core-java-modules/core-java-concurrency-basic-2/src/test/java/com/baeldung/concurrent/interrupt/InterruptExampleUnitTest.java +++ b/core-java-modules/core-java-concurrency-basic-3/src/test/java/com/baeldung/concurrent/interrupt/InterruptExampleUnitTest.java @@ -1,7 +1,7 @@ package com.baeldung.concurrent.interrupt; -import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -9,23 +9,23 @@ public class InterruptExampleUnitTest { @Test public void whenPropagateException_thenThrowsInterruptedException() { - assertThrows(InterruptedException.class, () -> InterruptExample.propagateException()); + assertThrows(InterruptedException.class, InterruptExample::propagateException); } @Test public void whenRestoreTheState_thenReturnsTrue() { assertTrue(InterruptExample.restoreTheState()); } - + @Test public void whenThrowCustomException_thenContainsExpectedMessage() { - Exception exception = assertThrows(CustomInterruptedException.class, () -> InterruptExample.throwCustomException()); + Exception exception = assertThrows(CustomInterruptedException.class, InterruptExample::throwCustomException); String expectedMessage = "This thread was interrupted"; String actualMessage = exception.getMessage(); assertTrue(actualMessage.contains(expectedMessage)); } - + @Test public void whenHandleWithCustomException_thenReturnsTrue() throws CustomInterruptedException{ assertTrue(InterruptExample.handleWithCustomException()); diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 809aa72966..8404d75024 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -46,6 +46,7 @@ core-java-concurrency-advanced-4 core-java-concurrency-basic core-java-concurrency-basic-2 + core-java-concurrency-basic-3 core-java-concurrency-collections core-java-concurrency-collections-2 core-java-console