Simplest JavaScript Deadlock
It's just another basic test to understand better JavaScript asyncronous queues and it could crash your browser or freeze them.
It's a deadlock, because while loop is waiting that condition is setted to false while timeout, the one who'll set that condition to false, is waiting while loop end to be executed.
THe same behaviour is expected with Ajax or every other async interaction.
This is JavaScript, have fun :-)
var loop = true,
block = setTimeout(function(){loop = false}, 1);
while(loop);
It's a deadlock, because while loop is waiting that condition is setted to false while timeout, the one who'll set that condition to false, is waiting while loop end to be executed.
THe same behaviour is expected with Ajax or every other async interaction.
This is JavaScript, have fun :-)
Comments
Post a Comment