Home arrow JavaScript arrow Javascript and HTML5 Web Workers: the close method

Javascript and HTML5 Web Workers: the close method

In this third part of a series you will learn how to build multithreading applications using Javascript web workers and HTML5.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 4
June 20, 2011
  1. · Javascript and HTML5 Web Workers: the close method
  2. · Using Multiple Javascript Web Workers
  3. · HTML5 Javascript close method

print this article

Javascript and HTML5 Web Workers: the close method
(Page 1 of 3 )

If you think building multithreaded applications is only possible in well-established programming languages like Java and C++, think again; web workers, a whole new sort of JavaScript object packaged with HTML5, allow you to execute (in parallel) a number of processes entirely independent from the browser’s API thread.

Supported by most modern browsers (with the exception of Internet Explorer, although rumors are that the final release of its version 9 will let you use them in a pretty standard fashion), web workers can be easily reached from the main web page through a simple messaging API, whose main elements are the “onmessage” event handler and the “postMessage()” method. The use of this tandem makes it really simple to dispatch messages to one or multiple workers - and in turn - receive responses from them for further manipulation.

In earlier chapters of this series I developed a couple of examples which demonstrated how to interact with a single worker from a main script, and how to spawning multiple workers.

If you missed those parts - or would like to refresh your memory - you can find them here:

While the examples above were hopefully helpful, you may be wondering if it’s possible to stop the web workers from the main script. Well, the answer is an astonishing yes! Effectively, the API includes a method called “close()”, which permits you to close the thread associated to a specific worker.

In the lines to come I’ll be setting up another basic example, which will illustrate how to use the “close()” method to stop a single web worker from a main web page.

blog comments powered by Disqus

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials