Simpler use of multithreading in Kotlin
@Test
fun mapMultithreading() {
(1..10).mapMultithreading {åçç
println("--->${Thread.currentThread().name}")
Thread.sleep(1000)
}
}
@Test
fun mapMultithreadingWithCount() {
val resultList = (1..10).mapMultithreading(10) {
Thread.sleep(1000)
Thread.currentThread().name
}
resultList.forEach { println(it) }
}
@Test
fun mapMultithreadingWithReturn() {
val resultList = (1..10).mapMultithreading {
Thread.sleep(1000)
return@mapMultithreading Thread.currentThread().name
}
resultList.forEach { println(it) }
}
<dependency>
<groupId>me.kagura</groupId>
<artifactId>harrier</artifactId>
<version>1.3</version>
</dependency>