i use a variable to limit the query operation of users,just like the critical area of OS。
//call 'fun' only if it is free(at the end of fun ,it will do isQuery=true)
var getInfo= function(param,callback){
if(!isQuery){
isQuery = true;
fun(param,callback);
}
}
but when two query requests happened at the same time, the param
went wrong ,like A recieved param
of B while B didn't call fun successfully! I think it is a multithreading problem,
When A was authorized (isQuery == false
) to call 'fun',and just before the sentence 'fun(param,callback)
' was going to execute, B called getInfo
,and passed new param
and callback
to getInfo
,but now,isQuery == true
, B is not authorized,then getInfo
tured to execute fun(param,callback)
with B's arguments,so it went wrong,i'm right?
ps: please forgive my poor english...
ps2:thank you very much,but i still feel unsure, maybe it is not a multithreading problem,but how does that happen?there is only one instance of 'getInfo',so will it always keep the latest argument?