Skip to content

Instantly share code, notes, and snippets.

@melissamarima
Created October 18, 2015 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melissamarima/4398bc65ab91c9771b8c to your computer and use it in GitHub Desktop.
Save melissamarima/4398bc65ab91c9771b8c to your computer and use it in GitHub Desktop.
Trying to understand JS concurrency
function sum(x, cc) {
setTimeout(function() {
cc(x.l + x.r);
}, 100);
}
var a = {
l: 1,
r: 3
},
b = {
l: 4
};
var A = sum(a, function(r) {
sum({
l: b.l,
r: r
}, print);
});
var B = setTimeout(function() {
a.l = 3;
}, 10);
var C = setTimeout(function() {
b.l = 6;
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment