It didn't work.
the second process can lock the file only after opening it for write/read. When the 1st file has locked the file, how can the second file open it for write/read? So before the 2nd process opens the file, it needs to check if the 1st process(or any other process) has locked the file. If so, the 2nd process should wait till the 1st process releases the file and then open the file and lock it.