- Does it lock the file before it deletes it?
- Does it need to?
- If it does not perform file locking how can I make it safe between multiple processes?
Asked
Active
Viewed 2,051 times
0
-
`safe between multiple processes`. It is called `thread safe` – Cole Tobin Jun 13 '12 at 02:15
-
@Cole Johnson what are you saying is incorrect – Op De Cirkel Jun 13 '12 at 02:16
-
Keep in mind that file deletion is handled natively, so you won't necessarily encounter alike performance on differing operating systems. – FThompson Jun 13 '12 at 02:18
-
A thread is a unit of work within a process. A process is a unit of work in the operating system. Multi-threading and Multi-processing are two very different things. – TofuBeer Jun 13 '12 at 02:45
1 Answers
2
Maybe this link will explain better. As far as I understand, deletion is an atomic operation so it does not need to lock the file. However, upon looking further, I found this link which shows the OS dependent nature of the delete operation. On Windows, it will necessarily need the file to be without a lock to delete it while on Linux you can delete a file while another process is using it.

Community
- 1
- 1

vellvisher
- 484
- 4
- 12
-
whether or not deletion will succeed on a locked file is operating system specific. – jtahlborn Jun 13 '12 at 02:23
-
@OpDeCirkel - except being completely wrong about the File.delete part. – jtahlborn Jun 13 '12 at 02:41