ribesg
01/18/2023, 2:34 PM@Test
    fun test() {
        val threadPool = newFixedThreadPoolContext(8, "TestDispatcher")
        val scope = CoroutineScope(threadPool)
        val atomic = atomic(0L)
        repeat(100_000) {
            scope.launch {
                atomic.incrementAndGet()
            }
        }
        assertEquals(100_000, atomic.value)
    }jw
01/18/2023, 2:35 PMribesg
01/18/2023, 2:36 PMribesg
01/18/2023, 2:38 PM@Test
    fun test() = runBlocking {
        val threadPool = newFixedThreadPoolContext(8, "TestDispatcher")
        val scope = CoroutineScope(threadPool)
        val atomic = atomic(0L)
        val jobs = (1..100_000).map {
            scope.launch {
                atomic.incrementAndGet()
            }
        }
        jobs.joinAll()
        assertEquals(100_000, atomic.value)
    }