JavaScript deadlock -
here saw javascript deadlocks , code:
var loop = true, block = settimeout(function(){loop = false}, 1); while(loop);
it's infinite loop , causes browser freezing. it's said deadlock created when 1 operation wait 1 executed , vice-versa
.
question is, except that, kind of situations deadlock occurs , ways avoid them?
that's not deadlock, infinite loop, can't have deadlock in javascript can't have more 1 thread accessing data.
what happens here loop never ends , js engine being mono-thread (regarding script), scheduler never calls callback give settimeout
. in fact have had same behavior without second line.
Comments
Post a Comment