Split or move core-java-modules/core-java-concurrency-basic module (#7799)
This commit is contained in:
parent
dac59fbec2
commit
6073d2d451
10
core-java-modules/core-java-concurrency-basic-2/README.md
Normal file
10
core-java-modules/core-java-concurrency-basic-2/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
=========
|
||||
|
||||
## Core Java Concurrency Basic 2 Examples
|
||||
|
||||
### Relevant Articles:
|
||||
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
|
||||
- [wait and notify() Methods in Java](https://www.baeldung.com/java-wait-notify)
|
||||
- [Difference Between Wait and Sleep in Java](https://www.baeldung.com/java-wait-and-sleep)
|
||||
- [Guide to the Synchronized Keyword in Java](https://www.baeldung.com/java-synchronized)
|
||||
- [Life Cycle of a Thread in Java](https://www.baeldung.com/java-thread-lifecycle)
|
33
core-java-modules/core-java-concurrency-basic-2/pom.xml
Normal file
33
core-java-modules/core-java-concurrency-basic-2/pom.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<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>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>core-java-concurrency-basic-2</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-concurrency-basic-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>core-java-concurrency-basic-2</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,19 @@
|
||||
<?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>
|
||||
|
||||
<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>
|
||||
</configuration>
|
@ -1,15 +1,15 @@
|
||||
package com.baeldung.concurrent.waitandnotify;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class NetworkIntegrationTest {
|
||||
|
@ -3,18 +3,13 @@
|
||||
## Core Java Concurrency Basic Examples
|
||||
|
||||
### Relevant Articles:
|
||||
- [Guide To CompletableFuture](http://www.baeldung.com/java-completablefuture)
|
||||
- [A Guide to the Java ExecutorService](http://www.baeldung.com/java-executor-service-tutorial)
|
||||
- [Guide to java.util.concurrent.Future](http://www.baeldung.com/java-future)
|
||||
- [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep)
|
||||
- [Guide to the Synchronized Keyword in Java](http://www.baeldung.com/java-synchronized)
|
||||
- [Overview of the java.util.concurrent](http://www.baeldung.com/java-util-concurrent)
|
||||
- [Implementing a Runnable vs Extending a Thread](http://www.baeldung.com/java-runnable-vs-extending-thread)
|
||||
- [How to Kill a Java Thread](http://www.baeldung.com/java-thread-stop)
|
||||
- [ExecutorService – Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads)
|
||||
- [wait and notify() Methods in Java](http://www.baeldung.com/java-wait-notify)
|
||||
- [Life Cycle of a Thread in Java](http://www.baeldung.com/java-thread-lifecycle)
|
||||
- [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable)
|
||||
- [Guide To CompletableFuture](https://www.baeldung.com/java-completablefuture)
|
||||
- [A Guide to the Java ExecutorService](https://www.baeldung.com/java-executor-service-tutorial)
|
||||
- [Guide to java.util.concurrent.Future](https://www.baeldung.com/java-future)
|
||||
- [Overview of the java.util.concurrent](https://www.baeldung.com/java-util-concurrent)
|
||||
- [Implementing a Runnable vs Extending a Thread](https://www.baeldung.com/java-runnable-vs-extending-thread)
|
||||
- [How to Kill a Java Thread](https://www.baeldung.com/java-thread-stop)
|
||||
- [ExecutorService – Waiting for Threads to Finish](https://www.baeldung.com/java-executor-wait-for-threads)
|
||||
- [Runnable vs. Callable in Java](https://www.baeldung.com/java-runnable-callable)
|
||||
- [What is Thread-Safety and How to Achieve it?](https://www.baeldung.com/java-thread-safety)
|
||||
- [How to Start a Thread in Java](https://www.baeldung.com/java-start-thread)
|
||||
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
|
||||
|
@ -1,14 +1,16 @@
|
||||
package com.baeldung.concurrent.threadsafety.tests;
|
||||
package com.baeldung.concurrent.threadsafety;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import com.baeldung.concurrent.threadsafety.callables.CounterCallable;
|
||||
import com.baeldung.concurrent.threadsafety.services.Counter;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class CounterTest {
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CounterUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCalledIncrementCounter_thenCorrect() throws Exception {
|
@ -1,14 +1,16 @@
|
||||
package com.baeldung.concurrent.threadsafety.tests;
|
||||
package com.baeldung.concurrent.threadsafety;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import com.baeldung.concurrent.threadsafety.callables.ExtrinsicLockCounterCallable;
|
||||
import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class ExtrinsicLockCounterTest {
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ExtrinsicLockCounterUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCalledIncrementCounter_thenCorrect() throws Exception {
|
@ -1,13 +1,16 @@
|
||||
package com.baeldung.concurrent.threadsafety.tests;
|
||||
package com.baeldung.concurrent.threadsafety;
|
||||
|
||||
import com.baeldung.concurrent.threadsafety.mathutils.MathUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class MathUtilsTest {
|
||||
public class MathUtilsUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCalledFactorialMethod_thenCorrect() {
|
||||
assertThat(MathUtils.factorial(2)).isEqualTo(2);
|
||||
assertThat(MathUtils.factorial(2)).isEqualTo(new BigInteger("2"));
|
||||
}
|
||||
}
|
@ -1,14 +1,16 @@
|
||||
package com.baeldung.concurrent.threadsafety.tests;
|
||||
package com.baeldung.concurrent.threadsafety;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import com.baeldung.concurrent.threadsafety.callables.MessageServiceCallable;
|
||||
import com.baeldung.concurrent.threadsafety.services.MessageService;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class MessageServiceTest {
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class MessageServiceUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCalledgetMessage_thenCorrect() throws Exception {
|
@ -1,14 +1,16 @@
|
||||
package com.baeldung.concurrent.threadsafety.tests;
|
||||
package com.baeldung.concurrent.threadsafety;
|
||||
|
||||
import com.baeldung.concurrent.threadsafety.callables.ReentrantLockCounterCallable;
|
||||
import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ReentrantLockCounterTest {
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ReentrantLockCounterUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCalledIncrementCounter_thenCorrect() throws Exception {
|
@ -1,14 +1,16 @@
|
||||
package com.baeldung.concurrent.threadsafety.tests;
|
||||
package com.baeldung.concurrent.threadsafety;
|
||||
|
||||
import com.baeldung.concurrent.threadsafety.callables.ReentranReadWriteLockCounterCallable;
|
||||
import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ReentrantReadWriteLockCounterTest {
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ReentrantReadWriteLockCounterUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenCalledIncrementCounter_thenCorrect() throws Exception {
|
||||
@ -17,8 +19,8 @@ public class ReentrantReadWriteLockCounterTest {
|
||||
Future<Integer> future1 = (Future<Integer>) executorService.submit(new ReentranReadWriteLockCounterCallable(counter));
|
||||
Future<Integer> future2 = (Future<Integer>) executorService.submit(new ReentranReadWriteLockCounterCallable(counter));
|
||||
|
||||
assertThat(future1.get()).isEqualTo(1);
|
||||
assertThat(future2.get()).isEqualTo(2);
|
||||
assertThat(future1.get()).isEqualTo(1);
|
||||
}
|
||||
|
||||
}
|
2
pom.xml
2
pom.xml
@ -407,6 +407,7 @@
|
||||
<module>core-java-modules/core-java-collections-array-list</module>
|
||||
<module>core-java-modules/core-java-collections-set</module>
|
||||
<module>core-java-modules/core-java-concurrency-basic</module>
|
||||
<module>core-java-modules/core-java-concurrency-basic-2</module>
|
||||
<module>core-java-modules/core-java-concurrency-collections</module>
|
||||
<module>core-java-modules/core-java-io</module>
|
||||
<module>core-java-modules/core-java-io-files</module>
|
||||
@ -1146,6 +1147,7 @@
|
||||
<module>core-java-modules/core-java-collections-array-list</module>
|
||||
<module>core-java-modules/core-java-collections-set</module>
|
||||
<module>core-java-modules/core-java-concurrency-basic</module>
|
||||
<module>core-java-modules/core-java-concurrency-basic-2</module>
|
||||
<module>core-java-modules/core-java-concurrency-collections</module>
|
||||
<module>core-java-modules/core-java-io</module>
|
||||
<module>core-java-modules/core-java-io-files</module>
|
||||
|
Loading…
x
Reference in New Issue
Block a user