Open the console to test web workers!
Find full documentation and code at: https://github.com/adussaq/amd_ww
Try the following in the console:
//Create arrays to store your jobs
workers1 = [];
workers2 = [];
//Initializes all the the workers
work1 = amd_ww.start({filename:'worker1.js'});
work2 = amd_ww.start({filename:'worker2.js'});
//Submit all of your jobs
workers1.push(work1.submit({a:7,b:2}).then(function(x){
//x contains the result of the job
console.log('7+2=', x);
}));
workers2.push(work2.submit({a:7,b:2}).then(function(x){
//x contains the result of the job
console.log('7*2=', x);
}));
//Utilize the 'all' property of Promises to run functions when all
//submitted jobs are done
Promise.all(workers1).then(function (x) {
console.log('Worker one all finished!');
});
Promise.all(workers2).then(function (x) {
console.log('Worker two all finished');
});
//Clear the workers to free up any memory
work1.clear();
work2.clear();