| Author |
Web Workers
|
Sunderam Goplalan
Ranch Hand
Joined: Oct 10, 2011
Posts: 55
|
|
Hi Rob,
I've heard web workers in HTML 5 does something similar to Threads in Java or another programming language. Where or what kind of real world scenarios can benefit from Web Workers?
Thanks!
G Sunderam
|
SCJP 5.0 , SCEA Java EE 5
|
 |
Rob Crowther
author
Ranch Hand
Joined: Nov 06, 2012
Posts: 165
|
|
|
Any time when you need to do processing in JavaScript that would last for a noticeable amount of time (ie. greater than 1/10th second) but not require access to the DOM (WebWorkers do not have access to window or document). WebWorkers communicate back to the parent web page through a message passing mechanism so it is easy to swamp any performance gains made through background processing in copying data between the two threads if you have a large dataset, however WebWorkers do have access to Ajax so if you wanted to request a large block of data from a server, do some complex processing and then deliver a relatively small result set to the page that would be an ideal scenario for them. There are some code examples in the spec which you may find helpful.
|
Read my books: Hello! HTML5 & CSS3 | HTML5 in Action
|
 |
 |
|
|
subject: Web Workers
|
|
|