For the onload 2 functions below which are scheduled to be called 'onload' of these 2 images, what guarantees that one will completely finish before the other begins? Is there a queue behind the scenes of callbacks that need to fire in this single threaded environment?
if entryFunction never stops looping, does it pause its thread and yield to one of the doWorks()?
I've heard that javascript is not multithreaded, so is the entryFunction() yielding/pausing to these asynchronous function calls?
function entryFunction() {
var obj = new Image();
var obj2 = new Image();
// ...
obj.onload = function() { dowork(); }
obj2.onload = function() { dowork(); }
while (1) {
console.log("Actual work is being done");
}
}
function dowork() {
doThis();
doThat();
}