Javascript Create New “Thread”

You are basically just taking the call to test out of the normal flow and the engine will execute the function whenever it fits, as soon as possible. That means, you are executing test asynchronously.

To make the code clearer, you could create a function with a meaningful name which does the same:

function executeAsync(func) {
    setTimeout(func, 0);
}

executeAsync(function() {
    alert("Test");
});

If you want to have real threads, have a look at web workers.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)