Article: Introducing Multithreaded Programming to JavaScript
In this article, which was originally published on InfoQ Japan, Daisuke Maki describes some of the challenges of developing responsive AJAX applications, and presents Concurrent.Thread as a solution to easing the complexity involved in asynchronous communcation in AJAX.
From the article:
While increasingly more websites are fully or partially based on AJAX, it is still difficult to develop complicated AJAX applications. What is the main issue which causes this difficulty in developing AJAX applications? Is it asynchronous communication with the server, or is it GUI programming? Both are routinely performed by desktop window applications -- so why is development of AJAX applications which do the same things particularly difficult?
[...]
Let me talk about Concurrent.Thread, a library that allows JavaScript to use multiple threads, since this greatly eases the difficulty associated with asynchronous communication in the AJAX development mentioned above. This is a free-software library implemented in JavaScript, available under the Mozilla Public License / GNU General Public License. You can download the source code from the website.
[...]
With Concurrent.Thread, it is possible to switch execution context from one thread to another as needed even if you write a long and continuous program. Let me briefly talk about how this behavior is achieved. In short, code conversion is used. Very roughly speaking, the function passed to the create() method is first converted to a character string, which is then rewritten so that it can be executed on a piecemeal basis. Then, the rewritten function is executed little by little on the scheduler. The scheduler is responsible for coordinating multiple threads. In other words, it makes adjustments so that each of the rewritten functions will be evenly executed. Concurrent.Thread actually does not create new threads but simply simulates a multi-threaded environment on the original single thread.
Read the full article here.
Huge js file
by
Sarath Chandra P
Re: Huge js file
by
Luciano Deriu
www.gidnetwork.com/tools/gzip-test.php
On my simple Apache server with the mod_deflate enabled the actually KB transferred is only 46KB!
This roughly equates to having a Flash object on your page... I can see when making real web applications having multi threading JS will help a lot. I haven't yet tested Concurrent, largely because of its initial 500kb file size but now after testing out the "real world" impact i feel its not much of an issue(assuming it does what it says on the tin).
Fascinating!
by
Frederick Polgardy
Error in code sample?
by
Inderjit Gill
var cache = {};
function getArticleWithCache ( id, callback ) {
if ( cache[id] ) {
callback(cache[id]);
} else {
getArticle(id, function( a ){
cache[id] = a;
callback(a);
});
}
}
script file
by
dma dma
the url does not work
thanks
Timer functionality in javascript.
by
Andrei Sedoi
Executing function on existing thread.
by
Andrei Sedoi
Could you please show me how can I execute some function on existing thread?
Is the function compilation recursive?
by
Nick P
However, if function A calls function C, I don't think function C gets compiled. So if function C is long-running, then it has no chance to yield.
Is this assessment valid or is there a way to address this?
Educational Content
Building Hypermedia APIs with HTML
Jon Moore Jun 19, 2013
Deleting Code at Nokia
Tom Coupland Jun 19, 2013
Intro to CLP with core.logic
Ryan Senior Jun 18, 2013
Spock: A Highly Logical Way To Test
Howard Lewis Ship Jun 18, 2013
Java Garbage Collection Distilled
Martin Thompson Jun 17, 2013




Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think