June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,30 @@
// version 1.1.51
import java.util.concurrent.SynchronousQueue
import kotlin.concurrent.thread
import java.io.File
val queue = SynchronousQueue<String>()
const val EOT = "\u0004" // end of transmission
fun main(args: Array<String>) {
thread {
var count = 0
while (true) {
val line = queue.take()
if (line == EOT) {
queue.put(count.toString())
break
}
println(line)
count++
}
}
File("input.txt").forEachLine { line -> queue.put(line) }
queue.put(EOT)
val count = queue.take().toInt()
println("\nNumber of lines printed = $count")
}