Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- fun outputstreamTest() {
- val myPool = newFixedThreadPoolContext(16, "MyPool")
- val inStream: MutableList<ByteOutputStream> = mutableListOf()
- for (i in 0..5) {
- inStream.add(ByteOutputStream())
- launch(myPool) {
- while (true) {
- inStream[i].write("${Thread.currentThread()}".toByteArray())
- Thread.sleep(1000)
- }
- }
- }
- inStream.forEach { stream ->
- launch {
- stream.newInputStream().bufferedReader().useLines {
- it.forEach {
- println(it)
- }
- }
- }
- }
- Thread.sleep(99999999)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement