Anonymous user
Synchronous concurrency: Difference between revisions
→Using coroutines: Use forEachLine over useLines; No need to close the file.
(→Using threads: Add a join, otherwise there is a race issue.) |
(→Using coroutines: Use forEachLine over useLines; No need to close the file.) |
||
Line 1,542:
===Using coroutines===
Uses experimental features and will change in the future. Same output as the threads version.
<lang kotlin>// version 1.3.20 with kotlinx-coroutines-core version 1.1.1▼
<lang scala>▼
▲// version 1.3.20 with kotlinx-coroutines-core version 1.1.1
import kotlinx.coroutines.async
Line 1,562 ⟶ 1,561:
}
File("input.txt").bufferedReader().
println("\nNumber of lines printed = ${count.await()}")
}
=={{header|Logtalk}}==
|