Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.76 KB | None | 0 0
  1. @Test
  2.     fun outputstreamTest() {
  3.         val myPool = newFixedThreadPoolContext(16, "MyPool")
  4.         val inStream: MutableList<ByteOutputStream> = mutableListOf()
  5.         for (i in 0..5) {
  6.             inStream.add(ByteOutputStream())
  7.             launch(myPool) {
  8.                 while (true) {
  9.                     inStream[i].write("${Thread.currentThread()}".toByteArray())
  10.                     Thread.sleep(1000)
  11.                 }
  12.             }
  13.         }
  14.  
  15.         inStream.forEach { stream ->
  16.             launch {
  17.                 stream.newInputStream().bufferedReader().useLines {
  18.                     it.forEach {
  19.                         println(it)
  20.                     }
  21.                 }
  22.             }
  23.         }
  24.         Thread.sleep(99999999)
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement