[JAVA-9895] Split concurrency-basic-2 module
This commit is contained in:
parent
ed09368f21
commit
e1212155fe
|
@ -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)
|
||||
|
|
|
@ -7,12 +7,6 @@
|
|||
</encoder>
|
||||
</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">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
|
|
@ -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)
|
|
@ -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>
|
|
@ -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>
|
|
@ -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());
|
|
@ -46,6 +46,7 @@
|
|||
<module>core-java-concurrency-advanced-4</module>
|
||||
<module>core-java-concurrency-basic</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-2</module>
|
||||
<module>core-java-console</module>
|
||||
|
|
Loading…
Reference in New Issue