File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Web Workers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Web Workers" Watch "Web Workers" New topic
Author

Web Workers

Sunderam Goplalan
Ranch Hand

Joined: Oct 10, 2011
Posts: 75
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, TOGAF Certified
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 297
    
    5

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 | Read my blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Workers