I have two JavaScript file for reading and writing a common text file. Created a task scheduler to run this JavaScript file at same time. So i need to implement lock concept in scripts. Is there exists any lock concept in JavaScript ?
More Clarification on Question:
I am not using node.js. simply it is a jscript file.
There is two Jscript file, File A and File B.
Both files are configured by a task scheduler at a time 10 am.
Both files are reading a text file D.Updates some text and write again to it.
If there occurs any resource starvation like, File A and File B are writing text file D at same time but different content.
try {
var objectFile = new ActiveXObject("Scripting.FileSystemObject");
var writingFile;
if(objectFile.FileExists(FileLocation))
{
var fileSpecified = objectFile.GetFile(FileLocation);
writingFile = fileSpecified.OpenAsTextStream( 8, 0 );
}
else
{
writingFile= objectFile.CreateTextFile(FileLocation, true);
}
writingFile.WriteLine(Date());
writingFile.WriteLine("test data");
writingFile.Close();
}
catch(e)
{
return true;
}