Another approach you can take is more complicated but more powerful/general. What you do is create a separate process, which is responsible (in this case) for deleting files. You then feed this process with a queue of file deletion requests. Since only one process is responsible for deleting files there cannot be any contention issues.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up