Threading: Ensure Thread-safety for temporary file creation