• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

FileLock in XP environment

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic