Skip to content

Commit 47b9795

Browse files
new module (#747)
* new module * delays * added readme file for this module * renaming file and package * commit * commit * commit Co-authored-by: Brandon Ward <[email protected]> * update * Spacing fix to re-trigger build. * update * fix test to past the CI build --------- Co-authored-by: Brandon Ward <[email protected]>
1 parent 3fe5b68 commit 47b9795

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Core Kotlin Concurrency
2+
3+
This module contains articles about concurrency in Kotlin.
4+
5+
### Relevant articles:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>com.baeldung</groupId>
6+
<artifactId>core-kotlin-modules</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
</parent>
9+
10+
<artifactId>core-kotlin-concurrency-3</artifactId>
11+
<packaging>jar</packaging>
12+
13+
<name>core-kotlin-concurrency-3</name>
14+
<url>http://maven.apache.org</url>
15+
16+
<properties>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>junit</groupId>
23+
<artifactId>junit</artifactId>
24+
<version>3.8.1</version>
25+
<scope>test</scope>
26+
</dependency>
27+
</dependencies>
28+
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.baeldung.comparedelays
2+
3+
import kotlinx.coroutines.delay
4+
import kotlinx.coroutines.runBlocking
5+
import kotlinx.coroutines.*
6+
7+
val lock = Object()
8+
9+
fun main() {
10+
runBlocking(Dispatchers.Default) {
11+
launch(Dispatchers.IO) {
12+
testWaitThread1()
13+
}
14+
launch(Dispatchers.IO) {
15+
testWaitThread2()
16+
}
17+
}
18+
}
19+
20+
fun testWaitThread1() = synchronized(lock) {
21+
lock.wait()
22+
println("Print first")
23+
}
24+
25+
fun testWaitThread2() = synchronized(lock) {
26+
println("Print second")
27+
lock.notify()
28+
}
29+
fun sleepMethod() {
30+
println("Thread 1 is sleeping...")
31+
Thread.sleep(2000) // Sleep for 2 seconds
32+
println("Thread 1 woke up!")
33+
}
34+
fun delayMethod() = runBlocking {
35+
println("Coroutine 1 is delaying...")
36+
delay(2000) // Delay for 2 seconds
37+
println("Coroutine 1 resumed!")
38+
}

core-kotlin-modules/core-kotlin-date-time/src/test/kotlin/com/baeldung/currentdatetime/CurrentDateTImeUnitTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class CurrentDateTImeUnitTest {
5353

5454
val current = LocalDateTime.of(
5555
calendar.get(Calendar.YEAR),
56-
calendar.get(Calendar.MONTH + 1),
56+
calendar.get(Calendar.MONTH) + 1,
5757
calendar.get(Calendar.DAY_OF_MONTH),
5858
calendar.get(Calendar.HOUR_OF_DAY),
5959
calendar.get(Calendar.MINUTE),

core-kotlin-modules/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<module>core-kotlin-string-conversions</module>
6262
<module>core-kotlin-files</module>
6363
<module>core-kotlin-operators</module>
64+
<module>core-kotlin-concurrency-3</module>
6465
</modules>
6566

6667
</project>

0 commit comments

Comments
 (0)