Merge pull request #11786 from hkhan/JAVA-9895-split-concurrency-basic-2-module

[JAVA-9895] Split concurrency-basic-2 module
This commit is contained in:
kwoyke 2022-02-07 16:19:42 +01:00 committed by GitHub
commit c94cbd9ed5
9 changed files with 55 additions and 13 deletions

View File

@ -12,7 +12,6 @@ This module contains articles about basic Java concurrency
- [Guide to AtomicMarkableReference](https://www.baeldung.com/java-atomicmarkablereference) - [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) - [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 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) - [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) - [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)

View File

@ -7,12 +7,6 @@
</encoder> </encoder>
</appender> </appender>
<logger name="org.springframework" level="WARN" />
<logger name="org.springframework.transaction" level="WARN" />
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
<root level="INFO"> <root level="INFO">
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>

View File

@ -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)

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-concurrency-basic-3</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-concurrency-basic-3</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<build>
<finalName>core-java-concurrency-basic-3</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -1,7 +1,7 @@
package com.baeldung.concurrent.interrupt; 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.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -9,7 +9,7 @@ public class InterruptExampleUnitTest {
@Test @Test
public void whenPropagateException_thenThrowsInterruptedException() { public void whenPropagateException_thenThrowsInterruptedException() {
assertThrows(InterruptedException.class, () -> InterruptExample.propagateException()); assertThrows(InterruptedException.class, InterruptExample::propagateException);
} }
@Test @Test
@ -19,7 +19,7 @@ public class InterruptExampleUnitTest {
@Test @Test
public void whenThrowCustomException_thenContainsExpectedMessage() { 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 expectedMessage = "This thread was interrupted";
String actualMessage = exception.getMessage(); String actualMessage = exception.getMessage();

View File

@ -46,6 +46,7 @@
<module>core-java-concurrency-advanced-4</module> <module>core-java-concurrency-advanced-4</module>
<module>core-java-concurrency-basic</module> <module>core-java-concurrency-basic</module>
<module>core-java-concurrency-basic-2</module> <module>core-java-concurrency-basic-2</module>
<module>core-java-concurrency-basic-3</module>
<module>core-java-concurrency-collections</module> <module>core-java-concurrency-collections</module>
<module>core-java-concurrency-collections-2</module> <module>core-java-concurrency-collections-2</module>
<module>core-java-console</module> <module>core-java-console</module>