Java FileChannel Concurrent Access
January 8th, 2008The JavaDocs for java.nio.channels.FileChannel includes the following (less than helpful) comment about the blocking behavior when using the non-position based methods:
Other operations, in particular those that take an explicit position, may proceed concurrently; whether they in fact do so is dependent upon the underlying implementation and is therefore unspecified.
It would be helpful if Google had any information about which platforms block concurrent access and which don’t, so I’m mentioning it here.
I downloaded the code under the JRL and had a look. The code for Solaris and Linux does not have any explicit synchronization on the position-independent methods. It calls the pread standard library function, which also allows concurrent access. I would assume that other Unix ports (including OSX) act the same.
The Windows port, however, includes a synchronized block prior to delegating to the native method. This is not unexpected… I am not aware of a way to do position-independent access to a file HANDLE in the Win32 API. Apparently Sun isn’t aware of any way either.
So, if you are unfortunate enough to have to target Windows, don’t use a single shared FileChannel across multiple threads. Otherwise, have at it.price viagra pharmacy online phentermine online description price best price 100mg viagra and overnight price of generic meridia effexor and topamax interactions aqnd anxiety buy sildenafil citrate lithium order the drug zyban cheap phentermine no rxx buy xanax prescription consultation overnight delivery buy flomax cheap phentermine online visa order xanax on br phentermine prescription amount soma cheap mastercard viagra equivalent for women online pharmacy and sildenafil citrate 25mg mexican pharmacy soma buy overnight phentermine 1 cialis tadalafil jpg buy hydrocodone onlin phentermine cheap online pharmacy buy generic meridia 15mg ha