Skip to content

Latest commit

 

History

History
44 lines (40 loc) · 1.13 KB

README.md

File metadata and controls

44 lines (40 loc) · 1.13 KB

harrier

Maven Central

Simpler use of multithreading in Kotlin

Example

@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) }
}

Getting started

<dependency>
  <groupId>me.kagura</groupId>
  <artifactId>harrier</artifactId>
  <version>1.3</version>
</dependency>