简体   繁体   中英

Does Java's SocketChannel$read() synchronize the output buffer?

Does Java's SocketChannel.read() method synchronize the output buffer?

In other words: is there a lock on the ByteBuffer argument passed to the read(ByteBuffer) method in java.nio.channels.SocketChannel (basically any channel). I need to know this so I don't have unnecessary synchronization blocks.

Java-Doc for SocketChannel says:

  • Socket channels are safe for use by multiple concurrent threads. They
  • support concurrent reading and writing, though at most one thread may be
  • reading and at most one thread may be writing at any given time. The {@link
  • #connect connect} and {@link #finishConnect finishConnect} methods are
  • mutually synchronized against each other, and an attempt to initiate a read
  • or write operation while an invocation of one of these methods is in
  • progress will block until that invocation is complete.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM