-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/jesperancinha/jeorg-kotlin-…
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../coroutines-crums-group-1/src/main/kotlin/org/jesperancinha/ktd/MainDispatcherLauncher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.jesperancinha.ktd | ||
|
||
import kotlinx.coroutines.* | ||
import org.slf4j.Logger | ||
import org.slf4j.LoggerFactory | ||
import java.time.LocalDateTime | ||
|
||
class MainDispatcherLauncher { | ||
|
||
companion object { | ||
val logger: Logger = LoggerFactory.getLogger(MainDispatcherLauncher::class.java) | ||
|
||
@JvmStatic | ||
fun main(args: Array<String> = emptyArray()) = runBlocking { | ||
runMainCoroutinesTest() | ||
} | ||
|
||
private suspend fun runMainCoroutinesTest() { | ||
try { | ||
val job = CoroutineScope(Dispatchers.Main).launch { | ||
launch { | ||
delay(100) | ||
logger.info("This is cat @ ${LocalDateTime.now()}") | ||
} | ||
launch { | ||
logger.info("This is mouse @ ${LocalDateTime.now()}") | ||
} | ||
logger.info("This is master @ ${LocalDateTime.now()}") | ||
} | ||
job.join() | ||
} catch (ex: IllegalStateException) { | ||
logger.info("Error!", ex) | ||
} | ||
} | ||
|
||
} | ||
} |