Two VMs and exclusive write access to one file

How can one guarentee exclusive write access to a file when two vms want to write to it?
I looked at
http://developer.java.sun.com/developer/JDCTechTips/2003/tt0304.html#2
However, I am not sure whether a race condition could happen or not.
(I thinking like:
if file is not writable, change to writeable,
else if file is writable, wait for a while and check again.
write what you want
change file back to not writeable.
Is there some OS level exclusive access thing we can take advantage of? The follow up question would be, what about system crashes?
Thanks.

The problem with what you describe is that two JVMs
could discover the file is not writeable at the same
time, and then change it to writeable. You need some
sort of action which can only be successfully
completed by one JVM. Here's an idea:
Create a dummy file which represents a "lock" (only
one JVM may hold the lock). When a JVM wants the
lock, it attempts to delete the file. This can only
succeed for one JVM. Once you have the lock, you do
your business and then restore the file.http://java.sun.com/j2se/1.4/docs/api/java/io/File.html#delete()
not bad. It's a false situation too.
However, deadlock can happen if the other VM goes down while the lock is taken.

Similar Messages

  • For some reason i have two accounts and I want to cancel one of them. they are yearly contracts but i dont want to pay double for the same product. How can I cancel one account?

    for some reason i have two accounts and I want to cancel one of them. they are yearly contracts but i dont want to pay double for the same product. How can I cancel one account?

    Is it possible that you are using the same password for the old O2 Study and newer O2 Apple Base Station networks?
    If so, Keychain Access is storing the old information about the old network and may be associating it with your AirPort Extreme settings based on the BSSID that William has mentioned.
    If that's the case, open Macintosh HD > Applications > Utilities > KeyChain Access and look for a listing with the old network name. Delete this entry. You may need to power down both the computer and the AirPort Extreme and restart them.

  • You know how you download apps, well let's say you have two devices and get an app on one and it goes to the other, how do you remove it from doing that?

    You know how you download apps, well let's say you have two devices and get an app on one and it goes to the other, how do you remove it from doing that?

    Click here and use the instructions to turn off the automatic downloads.
    (120206)

  • Write Access to a file in Tomcat server via J2me Midlet

    How to make write access to a file using midlet and HTTP connection?
    I have text file in the Tomcat server and I am able to read it with HTTP connection using emulator, but don't have idea how to make write access to the file. I'd like to write some text to the file.

    Thanks, but could you be more accurate. What methods should I use in the servlet and what methods in the midlet?
    Some links which concern this subject, would be nice too. I have tried with google, no success.

  • Once 10.9.1 is loaded onto my MacBook Pro and it has accessed all my files; is there anyway to back out of the relationship?  I don't want my data on iCloud - how do I make that happen?  Many thanks for any help.

    Once 10.9.1 is loaded onto my MacBook Pro and it has accessed all my files; is there anyway to back out of the relationship?  I don't want my data on iCloud - how do I make that happen?  Many thanks for any help.

    Sorry but I know of no way of not backing up for a PC.

  • Installed OSX 10.6.8 on iMac and now I have two icons in my dock for time machine and can't access either one.  I don't think it is backing up to time capsule either.  Anyone else have this issue?

    I installed OSX 10.6.8 on iMac and now I have two icons for time machine in my dock.  When I try to access either one the wheel goes round and round.  I seem to have lost all back ups that were on Time Capsule.  Not sure how to check or what to do.  Thanks.

    See what happens if you select the TM icon in your menubar, and select Enter Time Machine there.
    If that doesn't help, try the things in #E4 of Time Machine - Troubleshooting

  • How can I deny write access to datalog files for all but one process in LV8?

    In LabVIEW 7.1, wiring the deny mode terminal of Open File.vi with a Deny Write Only enum constant was an effective means for ensuring that only one process could write to a datalog file at a time.  In LabVIEW 8.0, Open File.vi is no longer available and the new Open/Create/Replace Datalog vi does not provide a deny mode terminal.  Also, the new Deny Access vi does not support datalog files.  Furthermore, the Set Permissions vi is an unsatisfactory solution because under the Windows operating system, it simply sets the Read Only file attribute.  This is inadequate because I have demonstrated that it is still possible for two processes to open a datalog file with read/write access before either one has had a chance to set the Read Only file attribute in order to lock out the file.  If a process sets the Read Only file attribute first, then it can't open the file with read/write access for itself.
    Does anyone understand the file mechanism by which deny mode used to work with the old Open File.vi?  I wish to restore the functionality I had in LV 7.1 in my LV 8 programs.
    Thanks!
    Larry

    Larry Stanos wrote:
    I appreciate the
    empathy from Rolf, but I'm hoping that someone may have written one or
    more vi's containing CINs that call Windows 2000/XP file access control
    library routines.  At least I'm assuming that is how the deny mode
    input to Open File.vi used to work in LV7.1.  The Microsoft
    Developers Network on-line documentation on Access Control http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthz/security/access_control.as... is
    daunting to put it mildly.  But even if a set of CINs has not
    already been coded, perhaps someone could point me to the specific set
    of calls I need to make to absolutely guarantee that no two
    clients can simultaneously open the same file with write privileges.   Unfortunately
    the elimination of deny mode functionality for datalog files in
    LV8 has sabotaged my commitment to a March 1 release date because it
    would also be impractical to convert everything back to LV7.1 at
    this point.   Sincere thanks to anyone who can help me out here!
    Unfortunately
    the functionality you mention does not work in the way the deny mode in
    the LabVIEW nodes works. Basically that deny mode is converted to an
    according FILE_SHARE_READ/FILE_SHARE_WRITE value and passed to the
    Win32 API CreateFile function. This is more or less the only place
    where you can define a global share (or deny) access to a file. That is
    also why the Deny Access node online help is talking about that the
    file is reopened.
    But I just retried what you had tried to do, and low and behold it
    works with wiring a datalog refnum to Deny Access. What is important
    here however is that you do need to wire a datatype to the record type
    input of the Open/Create/Replace Datalog node. Otherwise you can't
    connect the resulting datalog refnum to any other file function, since
    it is an incomplete datatype.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Authorization issues and no write access eventhough I am the admin

    Hello, I am having several issues with my itunes. I upgraded to the latest version 10.1 and have been having nothing but issues.
    Over 2000 of my songs that I purchased are now saying I do not have authorization to play them. When I right click on the songs it shows it was purchased with my itunes account. I have tried to deauthorize my account so that I could reauthorize it but it tells me I do not have write access. I have changed all the accesses on my account to everyone read & write but that did not help. I have repaired all applications access- still nothing. I tried to delete the SC INFO file but I do not even have one.
    I truly do not know what to do. This is very frustrating.

    I fixed it! Still curious as to why it happened though. I downloaded a nifty little app called "Batchmod" and reset all the permissions and removed ACL permissions? Then went to the terminal and typed
    killall Finder
    Boom! It worked! I hope this helps someone else in the future. Now if you know why it happened in the first place I would love to know.
    Cheers,
    Taylor

  • Live in Two States with two ISPs and need to merge into one account

    Surely I'm not the only one with this problem. And, I'd love to ask an Apple person, but I can't find the proper "contact us" phone or email! I'm 53 years old and not computer savvy. I first set up an itunes account on my computer in Reston, where it still resides in our house. Then, we got a small condo in NC and I set up itunes here. Except that it wasn't the same account I guess b/c it had none of my songs in it. So now, I have two sets of songs that I've bought in two different states and OF COURSE, now we're selling VA and going to be in NC full-time. I'd just like for Apple to tell me how to put the VA account and songs into the NC one so they'll be together. ARgh. Thanks for reading anyone. Abby

    Why do you have two account? There is no need for this. An account is just an id and password that you use to purchase music. You can use that account on any computer that has itunes.
    Your itunes library resides on your computer. You buy ONE download of a song. It is then up to your to back it up (in case of loss or crash) and to move it wherever you want it. Just like a cd. If you want that cd in another place you would have to take it there or make a copy and take the copy.
    Use your backup copy to move whatever music you like wherever you like, or copy to cd, dvd, external drive, flash drive, etc and move it to whatever computer you like.

  • How to read data from multiple files and append in columns in one file

    Hi Guys,
    I have a problem in appending data from files in different columns. I have attachement has file A and B which I am reading and not able to get data as in file Result.txt. Please comment on how can I do this
    Solved!
    Go to Solution.
    Attachments:
    Write to file.vi ‏13 KB
    A.txt.txt ‏1 KB
    B.txt.txt ‏1 KB

    You cannot append columns to an existing file. Since the data is arrange line-by-line as one long linear string in the file, you can only append rows. A new row needs to be interlaced into the original file, shifting everything else. If you want to append rows, you need to build the entire output structure in memory and then write all at once.
    (I also don't think you need to set the file positions, it will be remembered from the last write operation.)
    Unless the files are gigantic, here's what I would do:
    (Also note that some of your rows have an extra tab at the end. If this is normal, you need a little bit more code to strop out empty columns. I include cleaned up files in the attachment. I also would not call them A.txt.txt etc. A plain A.txt is probably sufficient.)
    EDIT: It seems Dennis's solution is similar )
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Write to fileMOD.zip ‏6 KB
    MergeColumns.png ‏6 KB

  • Networked computers need access to one file

    I don't know exactly where to post this message, but I'm starting here. If one of the mods believes it belongs in a different category, go ahead and move it with my blessing and eternal gratitude.
    Scenario: Office full of (10) macs. All running OS 10.4.x Networked and behind a firewall. Users are very very un-computer savvy and a little hesitant to try new things or do things that are not explained step-by-step. Each computer has its own user and they all keep separate files for documents. They cannot access each other's files/computers from their own work stations.
    Need: I need for them to be able to get to a common folder to access a single file. They will then modify the file and leave it there for others to access.
    Need: How do I set that up? How do I make it as easy as possible so they can all do it with a minimum of effort? It needs to be easy or they will not do it.
    All suggestions appreciated.
    Thanks in advance.

    You would use Personal FIle Sharing (and/or ftp), setting it up is easy:
    Apple Menu / System Preferences / Sharing.
    Turn on Personal File Sharing.
    Go to the Accounts preference pane now and create a new, non-admin account.
    I have mine setup for sharing and ftp, so I named the user ftp/dropbox.
    Now, when you activate ftp and personal file sharing, you can use the IP address of the Mac and the account for users to login.
    They would use the credentials for the account you created above in the Finder. Command-K or Go Menu / Connect to server...
    Once the volume is mounted, you can create a shortcut of it on the desktop like you do for any file.
    Make the ftp/dropbox account secure by using a good password.
    Depending on your network, you could ask for a static IP address, which makes it easier in case the DHCP (if used) gives a new address after a reboot of the "server"
    Scott

  • I received pictures in a dozen emails and saved each picture into one file in .pages.  I did not import the photos before doing this and now iPhoto won't recognize the pictures because they are in a .pages file.  How do I get the pics to iPhoto?

    I received a dozen pictures in a few emails and I saved them all into one file in pages.  I just copied and pasted.  I do not have the originals any longer.  Iphoto will not permit me to import the pictures as it does not recognize a .pages file, nor can I simply click and drag from the pages document to iphoto nor from pages to the desktop to iphoto.  How can I save each picture I guess back into a jpeg and then import them into iphoto or have i lost them to a pages document forever?  This is urgent as I need the pictures made into a book on iphoto for work by Friday!!!  Please advise!  Thank you.

    Greetings,
    Locate the Pages document wherever it's located on your computer and click once on it to highlight it.
    Go to File > Duplicate to make a backup copy of the file.
    Click once again on the file to highlight it.
    Go to File >  Get Info
    In the "Name & Extension" category remove the ".pages" extension and put in ".zip".
    Close the info window and double-click the now renamed pages file (zip file now).It will decompress into a folder which contains all the base components including all the images you added.  These can be dragged onto the iPhoto icon to import them.
    Hope that helps.

  • Merging PDFs and then saving them as one file in Leopard

    Would someone please tell me how I can merge PDF files into one PDF file. I have been able to drag and drop them together in Preview. I would love to be able to save the merged files into one file. Any ideas. I have read a lot online about this possibility in Snow Leopard, but I can't seem to save the dang file.
    Help.

    Open the first PDF. Open the tray so you can see the file on the left. Drag the other PDFs onto the first file in the tray. You can't just drag into the tray window anymore, you have to drag onto the file itself to merge. Save the file with new name.
    Macmost has a good podcast on this subject that came out about a week ago. Shows other PDF tricks with Preview as well.

  • Java.io.File and output.write to newly created file

    I'm using output.write(""); in conjunction with java.io.File to create a file with field data from a form submit. The file gets created and includes anything I add between the quotes rather then searching for it's value. My question is what is the syntax for putting <%= request.getParameters("") %> in the output.write brackets. I've been unsuccessful thus far so it must be my syntax.
    This works:
    try {
    File outputFile = new File("/tmp/filename");
    outputFile.createNewFile();
    FileWriter output = new FileWriter(outputFile);
    output.write("text in the file");
    output.close();
    } catch (IOException e) {
    System.out.println("Caught IOException: " + e.getMessage());
    // or.....
    System.err.println("Caught IOException: " + e.getMessage());
    %>
    I need to include the below and have the file represent <HTML> for redisplay.
    <html>
    <title><%= request.getParameter("car") %>, <%= request.getParameter("color") %></title>
    <font color=blue>Car Model: </font> <%= request.getParameter("carMod") %><br><br>
    <font color=blue>Car Color: </font> <%= request.getParameter("carColor") %><br><br>
    Can I wrap this somehow or do I need to define the field data another way?
    tks

    1)Do you want "<%= request.getParameter("car") %>" written exactly as that to the file, or 2)do you want to get the value of request.getParameter("car") and write it to the output?
    If 1):
    output.write("<title><%= request.getParameter(\"car\") %>,"+
            " <%= request.getParameter(\"color\") %></title>");else if 2):
    output.write("<title>"+ request.getParameter("car") +", "+
            request.getParameter("color")+"</title>");

  • Evevy song i have is duplicated, i try to delete the old one, but if i do, the new one dissapears also, i saw at the explorer window and every song is just one file

    My library is duplicated, i did what the support suggest but if i delete the old song the new one also dissapears, i reviewed the windows file and only appears one file, i try to find an answer but do not have yet any.

    I've written a script called DeDuper which can help remove unwanted duplicates. See this  thread for background.
    tt2

Maybe you are looking for

  • I want data series in Keynote chart to enter one at a time.

    In older version of Keynote, data series can enter one at a time. In version 6.2, seems all series enter at once. Can different series be made to enter one at a time in Keynote 6.2?

  • Reading Credit Card File (Oracle Cloud 11.1.9.0.0)

    Hi All. We have requirement to import Credit Card Transactions into Fusion Expenses to create Expense Reports. We are using Master Card so we cannot connect to the Bank's Server. 1. Can we upload the credit card file to UCM to import into fusion Expe

  • Do i need any extra equipment for triggering?

    Dear all, I have NI USB-6343 X Series Data Acquisition, I will collect data from loadcell, and according to the specific loadcell value, i will trigger a motor controller(which has also labview drivers), and tell motor controller to stop and go home

  • I just bought a whole album and 5 songs did not download on my iTunes, why?

    I just bought a whole album on my iPad and when it downloaded onto iTunes on my pc 5 songs came up with an error

  • Forms and MSWORD

    I use Forms 10g I found this code from Oracle's site I am new to Forms, my problem is How I do to get text ( that I modified in MSword) back in forms, DECLARE app CLIENT_OLE2.OBJ_TYPE; docs CLIENT_OLE2.OBJ_TYPE; doc CLIENT_OLE2.OBJ_TYPE; selection CL