SocketChannel bidirectional read/write
Sebastian Sickelmann
sebastian.sickelmann at gmx.de
Sun Jan 15 21:18:01 PST 2012
Am 29.12.2011 12:01, schrieb Hegewald:
> Hi all,
> from the Docs of SocketChannel:
> "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."
> I have a SocketChannel to which I write and read simultaneously (i.e. from two threads). On the remote host I do the corresponding read/write, also from different threads.
> If I now run the same setup with two SocketChannels (i.e. one to write to remote host, the other to read from remote host) the bidirectional throughput is about 35 % higher (the network hardware supports full duplex).
> Is this expected behaviour? Do I have to always create two channels to get the best results for bidirectional connections?
>
> Many TIA,
> -- Jan
Hi, i think it is because of the
synchronized (writeLock) {
and
synchronized (readLock) {
blocks.
Maybe there is a way to improve this to some amount of lesser locking.
But i haven't looked into this topic.
-- Sebastian
More information about the nio-discuss
mailing list