File IO: waiting for changes to be actually made to the filesystem

Hello.
I' ve multiple threads that access concurrently to a file.
The operations are:
-open the file file1
-copy some lines to a new file file2
-delete the old file file1
-rename file2 into file1
the method is synchronized.
The problem is that, even after I close the files and return from the method, changes are not still propagated to file system.
So, if the threads are fast, even if the second thread enter the method after the first has terminated, the old file has not yet been deleted and the second not yet renamed, or anyway "handles" to such files not yet been relased at file system level.
I don't have to guarantee high concurrency..so it would be just good for me to be sure that every thread will wait until all changes are made to the filesystem and all the handles have been released correctly.
How can I do that?
thank you very much.
PA
Edited by: Paranoid_Fabio on Sep 16, 2008 1:40 AM

My code is:
private synchronized void updateCodes(String path,User u,String code) throws IOException{
                //open the file
          File dumpfile=new File(path);
          if(!dumpfile.exists())
               dumpfile.createNewFile();
          RandomAccessFile rep=new RandomAccessFile(dumpfile,"r");
          //create the temp file
          File temp=new File(path+".tmp");
          temp.createNewFile();
          PrintWriter out=new PrintWriter(new FileWriter(temp));
          long pointer=rep.getFilePointer();
          while(pointer<rep.length()){
               //do some line copies from the first file to the temp one               
          out.flush();
          out.close();
          rep.close();
          //delete the first file and rename the second
          dumpfile.delete();
          temp.renameTo(dumpfile);
     }

Similar Messages

  • HT1351 My iPhone 5 will not sync music after I updated to the new iOS7. The message "waiting for changes to be applied" remains on the screen. I have restored my iPhone and reset it and nothing seems to be working.

    I even have the updated version of iTunes and I am not sure what else I am supposed to do.

    Yes, I have the exact same problem with my 4s! Updated to iOS 7 and can't sync. It's extremely frustrating, as music is crucial in my daily life.  I was able to remove all songs from my iPhone...and now when I try to sync the 4,000 or so I've selected, it will sync maybe 11 or 12 (if it gets past the "Waiting for changes to be applied" screen), and then just completely stop. No error code or anything. It just stops. It's driving me crazy.  See the following 2 links, one is a discussion I created and the 2nd is 5 or so people with the same issue.
    https://discussions.apple.com/message/23166612#23166612
    https://discussions.apple.com/message/23166607#23166607

  • ITunes stuck on "Waiting for changes to be applied"

    Here are the symptoms I'm seeing:
    - If I restore my phone, or delete/reinstall iTunes, or uncheck "Sync Music", wait for a sync to complete, recheck "Sync Music", ONE sync attempt will complete. I try adding one additional song and re-syncing the device, it gets stuck.
    - If a sync doesn't complete, it gets stuck on "Waiting for items to copy" or "Waiting for changes to be applied". Via fs_usage, it seems like nothing is happening during this phase. I've left it for two hours and it doesn't move on from this phase unless you manually cancel the sync.
    - It's manifested itself on two different phones - an iPhone 4S and a iPhone 6.
    - Each phone has enough space for the items I'm syncing
    - Sometimes iTunes or gets confused and moves the entire music library on my phone into "Other". Recently I had 42GB of "Other" on a 55GB device. See attached screenshot: http://monosnap.com/file/AaDzqWpgtNXtfTYdy8iscfTKrkZGWC
    - The problem has persisted across multiple versions of iTunes (at least versions 11 and 12)
    Here are the things I've tried to solve the problem:
    - Restore the device - as mentioned, works one time, further syncs fail
    - Turn my laptop off and on
    - Turn my phone off and on
    - Replace "iTunes Library.xml" by moving it to the Desktop and rebuilding the file (really fun as I lost all playlists, import date info and most played information by doing this)
    - uncheck Sync Music and recheck it - as mentioned above, this works one time, this method is also error prone (takes 3 or 4 canceled syncs before it decides to actually transfer the songs)
    - signed out of Apple Store
    - repair disk permissions
    - repair disk
    - trace iTunes process with fs_usage, will try dtruss next
    - remove the SyncServices/Local directory - didn't do anything
    - remove iTunes and every trace of it I could find (com.apple.itunes and related plist files) and reinstall from the Internet - I got one good sync after this and then it got stuck again.
    I would appreciate your help as I'm at wit's end here. If there are any debugging logs or further information I can post, please tell me - I'm a software engineer by trade and have a fairly good idea of how to operate a machine (though not really how to debug a closed-source binary, maybe I should learn how).
    Thanks,
    Kevin

    This problem started last year when ios 8 was released. I think apple is trying to force users to buy music on iTunes store and that's why it's impossible to sync other music and also that's the reason why they haven't solved this serious problem. That's really disappoints me and i'm angry with apple because i have like 10 gb of music in mp3 and i can't sync music from iTunes to my iPhone.

  • Solution: Syncing with my iTunes library an endless headache: Songs don't transfer, or songs transfer and show up as "other," or I get double copies, or "Over Capacity," or stuck on "waiting for changes to be applied."

    iPod Touch 5g, 64GB, iOS 7.1. After my iPod data began showing up "Other," after an abrupt disconnection from iTunes during a sync I've spent the last week trying to fix it only to be thwarted at every attempt.  I've tried resetting and restoring 6 or 7 times now, and all goes well until it gets to copying my library of music over.  What I finally figured out is that 8,000+ songs is too many for iTunes to process all at once for some reason. 
    After several nights of leaving it connected all night I would find that the songs had physically copied and were occupying the ~45 gb of space on my iPod's storage, but were not showing up on my local library, instead listed as "Other" in iTunes and otherwise unusuable, or they would show up, but I'd have ~45 gigs of "Other," 45 gigs of "Audio," and would be "Over Capacity," by 30 gigs or so.  OR it would be "Waiting for Changes to be Applied," for 12+ hours.
    My work around:  In iTunes, under the "Music" / "Sync Music" tab, instead of syncing "Entire Music Library," select "Selected Playlists, Artists, Albums, and Genres."  You will have to indivually select the playlists, artists, albums, or genres and kept each bulk tansfer to <2000 songs at a time.  The easiest way for me to do this was by selecting one genre at a time and copying it over.  I had already taken the time to organize my library into 10 genres, you probably have more than 10.  This is irritating and time consuming, but it's better than resetting my iPod over and over and over again to no avail.
    Waiting for Changes? What iTunes is actually doing when it says it is "Waiting for Changes," or "Waiting for Items to Copy."  iTunes for whatever reason does not reveal the relevent data being processed during a sync (didn't it used to?), but there are a couple ways you can decipher what it is actually up to.  The first option is on the iPod; under Settings>General>iTunes Wi-Fi Sync it will tell you what it is up to during syncing.  The other way on the iPod; under Music>Songs, scroll all the way to the bottom to see where it is at in the process.  What iTunes, iTunes Wi-Fi Sync, and the bottom of the Songs library report are not always in agreement, but seeing all three will give you a better approximation of where you are in the syncing process and whether or not it is hanging.
    This for me was successful as a workaround, but this is not a solution.  Apple needs to fix this crap.  Maybe they just want to make it so difficult to have a physical library of music on the local storage of the iPod that we will just give up and sign up for their Match service.

    ALSO, on the iPod under Settings>General>iTunes Sync, you may need to back out of the "iTunes Wi-fi Sync," and reopen it to get it to update.
    (I use iTunes 11.1.5.5)

  • Ipod touch 3rd generation is stuck in "waiting for changes to apply" during sync

    My iPod touch 3rd generation is stuck at "waiting for changes to apply" during sync.  I have the latest update and the latest version of iTunes downloaded.  Any suggestions for a remedy to this problem?  Thanks!

    Here is the link for the downgrade from Apple.
    Link: http://support.apple.com/kb/DL1103
    Here is the Link before you install Apple 10.3 downgrade Read Oct. 17th the 1st on of the 17th.where I said "A" OKAY
    Link: https://discussions.apple.com/message/16500143#16500143
    I went into my desktop PC the to Start/My music/iTunes folder.
    In my folder there was nothing called ITunes Library.itl., but I had file called iTunes Library, in the center of it labeled "Lib", so I re-named it to "iTunes Library.itl.backup" Then went to the folder from iTunes" Previous iTunes
    Library" and copied and pasted mine was iTunes Library 2011-04-02 right into the iTunes main folder.
    Close your iTunes folder and then install the previous ver. 10.3 of the Apple link. I did not reboot PC. Did not use Cc cleaner nor add/Remove. then after 10.3 said finished installing 10.3 I clicked on my iTune Icon and iTune came up, iPod not plugged in yet.
    Then I clicked on "let iTune to find all my music and install them", said towards bottom of iTunes.
    Why we don't have the answer but iTune will put all your music in but you will have duplicates of the songs, so you will have your work cut out for you, takes time. plus some of my Artwork was missing, but I save that too.
    I'm not Responsible for this instructions, this is what worked for me.
    I think everything here is in order. Lot of my information came from all of you guys.Thank you. took a lot of reading, and trial and errors 2 1/2 day latter.

  • Error in work flow wait for change event

    Error in work flow wait for change event of business object bus1014, Actually this business object is triggering for two transaction one is me21n and another is c201 . am trying to create fork with two branches one is create and another if change occurs wait will trigger, bt when i trigger work flow controll is not after fork, it will stop in fork only. and am not getting my workflow container variable getting instantiate, am getting error in wait. please any one get out of me in this

    Hi Sangeetha
    What is LV_MATERIAL? is it a BO container element? or a class element or a just a simple variable?
    Error message is clear, you are trying to evaluate LV_MATERIAL but it does not contain a value.
    This is a custom workflow as it begins with WS9xxxxxxx... what is LV_MATERIAL used for? what are we expecting it to hold? maybe, from event to workflow binding we can pass the value to it.
    Please share the following:
    1) Definition screen shot of LV_MATERIAL
    2) Screen shot of The step where it is first used - from SWDD
    3) Screenshot of Event to Workflow Binding
    4) name of your base Business Object (seen in the triggering events tab of the WF template in PFTC)
    5) What is the corresponding variable for that BO in your workflow container
    6) Screen shot of WF definition from SWDD - please identify the step going in error in that screen shot
    Regards,
    Modak

  • Windows 8.1, iOS 8.1.3, Itunes 12.1 64 bit, constantly get 'waiting for changes to apply' when trying to sync my new ipod touch

    Windows 8.1, iOS 8.1.3, Itunes 12.1 64 bit, constantly get 'waiting for changes to apply' when trying to sync my new ipod touch. Downloaded latest version f itunes, and ipod software up to date. Really frustrated I can't sync my music! Please can someone help me

    Im having huge issues after updating to 12.1 on Win 8.1  x64. Choppy playback and so on.
    Try this since it helps in most situtation :
    Remove itunes but keep library files. Then download it again and install it.
    Also most likely you will have to restore ipod touch. I restored my iPhone 5 to remove waiting for changes to apply and Error 54.
    my iPad air still isnt restored (cant do it now) and it sometimes does same like iPhone waiting for changes to apply. And gives error 54 but sync DOES GET COMPLETED.
    Also may sound stupid but try to use USB 2.0 Ports. Not 3.0. I have troubles when using 3.0

  • Trying to transfer purchases from my 3gs onto a new PC (Vista).  Keep getting the message "Waiting for changes to be applied".  HELP!

    Using the latest version of iTunes and iOS5 on my iPhone.  Backup of the iphone seems to work fine.  My old PC died and I want to transfer my apps to my new PC.  But when I start Transfer purchases from my iPhone, it just keeps giving the message "Waiting for changes to be applied" and doesn't do anything.  I'm getting worried as I have an iPhone 4s coming and I want to move my 3gs stuff over to my new phone.  Anyone know how to fix this?

    Had the same thing happen to me a few weeks back when I switched computers and migrated.  Here's what worked on my iMac, so maybe it'll work on your iPad, too.  Go to User(your home folder)/Music.  Select/highlight your "Music" folder.  Then do Command-I ("Get Info" from the File menu), click on the padlock icon in the lower right of the new window.  Enter your user password.  Click on your username just above the now-open padlock.  Select "Read & Write" if it's on "Read Only," "Write Only," or "No Access."  Now having your user account with "Read & Write" privileges (it may have been this way already; still do this next step), click on the gear on the bottom-center of that window.  Click on "Apply to all enclosed items."  When the pop-up says "Are you sure?" (or the equivalent), say "yes."  This will grant access privileges to your user account for all the music files inside your music folder--all your iTunes stuff included).  Then you should be good to go.

  • Brand new iphone 5 says waiting for changes to be applied forever, every time I sync my phone.

    I previously had an iphone 4, and after backing up everything, i bought an iphone 5 and transfered everything to the new phone when i was at the apple store. i brought my laptop to get help syncing the music, but it gets stuck in a perpetual loading screen and gets stuck on waiting for changes to be applied. i cannot cancel the sync unless i eject my phone. and when i do, all of the music is greyed out, when i plug my phone in again, it starts syncing and stops when it says waiting for changes to be applied, or sometimes copying files. ive restarted my computer, my phone, un-plugged and plugged back in, everything is up to date, i un-installed and then re-installed itunes and nothing seems to work. i could sync everything fine before when i had the ophone 4. i have an HP laptop with windows 8 and i core 7, and theres a label that says nvidia geforce gt 635 (hopefully the info helps)
    Can anybody please help me with this?

    so i went back to the apple store and the only solution was to trade in your phone for a new one because there was a faulty conector in the microport. hopefully you have a waranty and your stuff backed up!

  • Following iOS7 update, sync hangs on "Step 6: Waiting for changes to be applied"

    Just updated to iOS7.  Everything seems be be working fine except for the fact that I can't sync my phone.  It stalls on "STEP 6: Waiting for changes to be applied."
    Anyone else having this problem?

    I'm curious if the folks on this or the other threads dedicated to this problem have pretty substantial (say, over 25 GB) music files.
    I ask because the simplest thing seems like it solved it for me. Every sync since downloading ios 7 and itunes 11.1 encountered this problem. I did all the resets of my device and Macbook Air, re-installed itunes, factory reset on my iphone (4s), turned off Genius and Find My Phone, double checked my download file in itunes, deleted all my voice memos, deleted all my media and then re-installed it, basically any of the suggestions I came across on the discussion boards or were recommended during any of my three Apple support chat sessions, it still hung up every time resulting in partial or complete deletion of my music and other media.
    Then this evening for the first time I fought the urge to cancel the sync when it seemingly got stuck and I just let it go. Well over an hour later the sync finished seemingly normally and since then it's been fine, syncing just as quickly as it always used to. I've got about 43GB of music that syncs every time, I wonder if there isn't something that the new itunes/ios needs to do to the individual files that just takes awhile. My wife updated to ios 7 on the same day I did and never had this issue, the only noticeable difference between our phones is the size of our respective music libraries.

  • IPod Touch 5th Generation sync stuck on "Waiting for Changes to be applied" what do I do?

    Brand new ipod touch 64GB will not sync with my itunes account.  I have an older ipod with more than 12,000 songs that syncs with no issues but when I try to sync this new one it gets stuck on step 4 and it states, "Waiting for Changes to be applied" and does nothing else. I will give this a little more time before sending it back for a refund and never buying another apple product.  You would think that a device who's primary job is to hold and play music from its own website could actually work. (running version 7.1.2)

    Re: "Waiting for changes to be applied"

  • IPhone 6 won't sync-- stuck at "waiting for changes to be applied"

    New iPhone 6, wouldn't sync to iTunes in Windows 7. made it to "waiting for changes to be applied" and would go no further. left it overnight, even.
    This morning, I went through the steps detailed in other troubleshooting threads (signing out of iTunes store, rebooting phone, restarting iTunes, getting to that same step and ending sync by clicking the x) and it started syncing!
    But...  I have the 128G iPhone, and I needed to leave for work. 90 minutes into the sync, I had to stop the sync.
    Now I'm back at the same error, have redone all the same steps, even updated to 8.0.2, and still "waiting."
    Step 5 of 5, waiting for changes to be applied.
    What can I do?

    OK this is what I did:
    Did a backup of my iphone to itunes & unplugged phone from computer.
    Did a erase & reset on my phone to clear all data.
    Plugged phone back into my computer & did a restore from backup.
    Phone is now syncing & also cleared out the very large mysterious "other" file.
    I can't believe tech support told me to uninstall itunes!!

  • "Waiting for Changes" NEEDS TO GET FIXED

    How is it that Apple can't send out a fix for the "waiting for changes to be applied" error when syncing an iPhone using iTunes? There are a ton of threads on this topic. FIX IT!
    While you're at it, fix the "other" data problem. I can't get rid of it unless I restore from backup (which takes a long time) and it happens to me far too often (like every time I sync my phone.
    These are known problems and should have a real solution other than "restore from backup."
    That is all.

    Both of your issues are going to be related to a corrupt file or files that you are syncing.

  • I cant sync downloaded music to my iphone, itunes stuck at waiting for changes to be applied

    I have a iPhone 4s ios 7.0.4 and i download some mp3 songs from mp3skull.com, but when i try to sync them to my iPhone from itunes it gets stuck at waiting for changes to be applied. and the songs wont sync. PLEASE HELP

    I have had this problem and I hope this works (it did for me and I also had an iPhone 4S - 7.1.2)
    1) Plug your iPhone in to iTunes.
    2) If it automatically starts syncing click the 'X' to cancel the sync as quickly as you can.
    3) Once the Sync has cancelled, navigate to:
    'File' > 'Devices' > 'Transfer purchases from "_______ iPhone"
    4) Wait for Purchases to transfer.
    5) Update Apps on iTunes.
    6) Wait for that to finish.
    7) Try and Sync again.
    8) This time it should work.
    ----CONTINUE READING IF THIS DOESN'T WORK----
    9) Click 'Restore iPhone'
    10) Let iPhone restore (could take 20 minutes)
    11) Set up as a 'New iPhone' and sync your music.
    ----OTHER THINGS TO CHECK BEFORE YOU RESTORE----
    1) Is your iPhone running the latest software version?
    2) Is your iTunes running the latest software version?
    3) Are your songs in an unsupported File format?
    4) Are your songs corrupted?
    5) Have you transferred purchases and updated all apps on iTunes?
    -----OTHER THINGS YOU COULD DO-----
    1) Re-install iTunes (could work - probably won't but you can give it a try)
    2) Delete all music off phone (again probably won't work but you could give it a try)
    3) Re-start your phone by holding the 'Home/Touch ID' button and the lock button at the same time and hold until the Apple logo appears.
    ----NOTES-----
    Since updating to iOS 8 and iTunes 12 I haven't had this problem.  You might want to update to iOS 8.1 and iTunes 12 - this could solve the problem too.
         Thanks
                  iPad iPhone Help.

  • Hi, I finally got lucky and past the "other" memory status issues when syncing. Now I'm "waiting for changes to be applied" sync stuck all night (itunes yesomite iPhone 6 plus). is this a bug? I have not had a single successful sync with yesomite.

    hi, I finally got lucky and past the "other" memory status issues when syncing. Now I'm "waiting for changes to be applied" sync stuck all night (itunes yesomite iPhone 6 plus). is this a bug? I have not had a single successful sync with yesomite.
    please help. this issue prevents music from syncing. I have set the sync setting to convert songs to 192kbps AAC to save space, I figure that could slow the sync
    down, but it's hanging indefinitely (I've left it for 24 hours with out it completing.)
    the the only music that appears on the phone are songs purchased from the iTunes Store. 95% of my collection are rips from my CDs.
    thank you for any help!

    Yeah it's pretty sad that $1000 phone they put out you such cheap memory It causes issues, I have iPhone 6+128 GB actually this is the second brand-new one they gave me because they keep affording it trying to act like that's not the issue because they're too stupid to know how to check what memory is in each one before they give it to me when I have told them multiple times my back up runs perfectly fine on two 5s phones and a 6 64GB of course running MLC memory.
    I told them it's because just like the write ups say I have 809 apps but I have not even put all my music on the phone so I'm still running 50 to 60 gigs free and it crashes and reboots itself sometimes in multitasking and more often than it does that in between multitasking I get a black screen for 1 to 2 seconds in between apps and upon start up the Apple logo screen will flicker and do weird things, One of the genius idiots asked me if I could just delete some of my apps, really that's the answer to fix the phone the customer needs to limit the amount to apps they put on their phone, why the **** get a 128 gig if you can't put on anything you want to it guess they need to start selling them saying you can only put a limited number of apps on them, it's really is a **** joke, I have over $20,000 of Apple merchandise easily and always get the new phone every year but I'm starting to reconsider my decisions in the future because this company is starting to go downhill, The reason water not recalling the phones is because they're dealing with their top-of-the-line thousand dollar phones in this case and most people don't have over two or 300 apps so they're not having as many issues, so basically they have messed up phones they just don't know it in their hands and Apple is just too **** greedy to recall the phones, they'd rather sell customer spends that only work half ***.
    Stuff like this will be the downfall of their company, all the people that stay with them because as long as you don't jailbreak their stuff it normally just works without issue will be soon jumping ship if stuff like this keeps up, because I can guarantee they got me thinking now.
    not that I wanted to know or should I be expected to but I even offered for them to open up my brand-new phone and just replace the memory to MLC memory which is something I shouldn't have to do with a brand-new **** phone, they should just make one with the right memory and give me a new phone, actually just don't sell customers that buy the top-of-the-line phone from you trash ones in the first place that would be a great option.
    what burns me up the most is when you talk to AppleCare and Genius Bar they try to act like the issue isn't there and they're unaware of it, they say that Apple hasn't come out with any information about it, yeah that's because they don't want to recall the trash.
    Apple has became nothing better than your run-of-the-mill company, android is becoming just as good as they are sad to say this since I have been an Apple fan for so long but there is no excuse for BS like this they have been looking for options to fix my phone for a month now this is not the way you should treat loyal customers, I would've been better off keeping my 5S and in the future just switching to android.
    it's pretty sad that the company has no idea how to check which memory is in their **** phone and even after I offered to let them just replace the memory in my new phone by opening up my brand-new phone to replace it they have no idea how to do that either, yeah Genius Bar sure, I think that should change the name to idiot bar and Apple don't care instead of Apple care.

Maybe you are looking for

  • Drawing a box in smartforms

    Hi, Is it possible to draw a box in smartforms in a non specific place on the page? Thanks Lindy

  • Add field in FBL3N Tcode Layout

    Hello All, I wish to add the field LGTXT (Wage Type Long Text) to be displayed in FBL3N.  How to add this field in the layout in FBL3N? Can we add this field? My idea is to view the Wage type text field when i hit the G/L Account and company code in

  • SAP IDES4.7EE..........Server starting problem

    Hi Friends....              I am using IDES 4.7ee.....while starting the server .....msg_server.exe is running but the  disp+work.exe has been stoped..and all the workprocees goes to run mode instead of  wait mode......How to solve this problem any b

  • Updated Instant Client 11.2 for Linux 64 bit is on OTN

    The 11.2 Instant Client for Linux 64bit has been updated on http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxx86_64soft.html It is now at the same patch level as 32 bit.

  • Slideshow BG Messing up

    Trying to make a slideshow in iDVD 6 but iDVD keeps messing up my images and is not rendering correctly. There should be one picture at a time, however, it layers 2-3 for each slide. I can't explain it very well and will upload a picture. http://i116