Aha, i didn't see that, sorry.
I guess you could use mutex for a file where you write all the other filenames and only one thread will access the file at one time, and then you're sure you have unique file names.
http://www.php.net/shm_get_var -- maybe it will be of some help