Java NIO Pipe vs BlockingQueue

后端 未结 4 2017
广开言路
广开言路 2021-02-04 12:04

I just discovered that just has an NIO facility, Java NIO Pipe that\'s designed for passing data between threads. Is there any advantage of using this mechanism over the more co

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 12:26

    I believe a NIO Pipe was designed so that you can send data to a channel inside the selector loop in a thread safe way, in other words, any thread can write to the pipe and the data will be handled in the other extreme of the pipe, inside the selector loop. When you write to a pipe you make the channel in the other side readable.

提交回复
热议问题