File.createNewFile() randomly fails

前端 未结 3 794
谎友^
谎友^ 2021-01-25 14:06

I\'ve build a simple test which creates and deletes a file (name does not change) in an infinite loop. The test does run for a couple of seconds (sometimes over 77,000 iteration

3条回答
  •  醉酒成梦
    2021-01-25 14:29

    I've found an explanation while writing the question. I still posted the question because I wanted to share what I learned.

    My application is not the only process on the system accessing files. The Windows Search Index Service for example could open this file because it wants to add it to it's index. Or the windows Explorer if it is updating the view.

提交回复
热议问题