People says that single-threaded languages like Javascript can not got that issue. However, nodejs provides cluster
to fork multiple workers. Is this gonna cause race condition
problem?
And also, I have an example that causes my confusion sometimes:
ALLSESSIONS = {};
//session id saved in cookie
ALLSESSIONS[sessionid] = 'somevalue';
var SESSION = ALLSESSIONS[sessionid];
... do stuff for sometimes
console.log(SESSION);
I'm afraid that when another request reaches node while the current request is still running, it may overwrite the SESSION
variable with its own session id, then the result of current request is undetermined
.
Is this gonna happen in node?