Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NIO, locking and Win-XP  RSS feed

 
Dennis Noren
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is reposted from Java in General, Intermediate. I had no response there, but this looks like a better place to post it.

I've searched for how Win-XP handles shared locks and exclusive locks under nio, but have been unable to find anything yet. I have one program that reads a file, and does a shared lock of part of the file, then waits. A second program attempts to access a different portion of the file (no overlap) for writing. I get the run-time IOException:
"The process cannot access the file because another process has locked a portion of the file". This happens whether I use shared lock or exclusive lock.

Does someone know what XP allows in this situation, or whether I may be doing something that won't work regardless of the OS environment?

Thanks.

Code snippet from first program:




Code snippet from second program:




(the IOException occurs on the FileLock statement)
 
Dennis Noren
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just thought I would bring this up again, in case someone can comment on it. I don't know if this is OS dependent or not. I don't have easy access to a platform other than Windows XP.

Puhhhhhhlease?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!