Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FileLock on file accessed from multiple virtual machines

 
Ravi Danum
Ranch Hand
Posts: 154
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I have a web service that allows a file to be uploaded. The web service can be deployed on multiple machines, but the file is to be stored within the same file system. Can I use java.nio.channels.FileLock and Filechannels to lock a file when it gets created so that no other upload will try and save the same file?

Thanks.

Ravi
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try it out with a little test program:
You start this code once, and don't press enter yet. You then start it again in another JVM. See what happens.
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!