Here is the scene about my problem.
I make a var dataCache, which buffers the data I achieve from remote server. I update dataChache every 30s, like this,
setInterval(function(){
instance.loadJsonFromRemote(configuration.dataUrl,function(data){
instance.dataCache = data;
});
}, 30000);
and dataCache probably would be accessed exactly at the same time when it's being updated.
For example,
var cool = instance.dataCache.cool
the code above runs while the data updating code runs,
instance.dataCache = data;
I guess the possible solution would be lock dataCache up while it is being accessed, if no one accesses it, it can be set.
I probably need something like lock in C#, but I don't really know how to do it in JavaScript, or maybe it is not even a problem in JavaScript, coz JS is single threaded and it works fine. I'm not very familiar with JS.