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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -