How to apply a lock to 2 functions so that the 1st function gets executed 1st and then the second function executes when called simultaneously.
The 2 functions are :
function f1(){
//some code here
}
function f2(){
//some code here
}
How to apply a lock to 2 functions so that the 1st function gets executed 1st and then the second function executes when called simultaneously.
The 2 functions are :
function f1(){
//some code here
}
function f2(){
//some code here
}
Functions in JavaScript aren't "called simultaneously" : there is only one user thread.
You don't have to put a lock, you have to look at how you call the functions. And probably you don't have to care.
If what you want is having two functions executed in order when the ajax requests are done, then you may use jQuery's promise system :
$.when($.ajax(...), $.ajax(...)).done(function(){
f1();
f2();
});