<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Ajax, javascript and threads : the final truth</title>
	<atom:link href="http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/</link>
	<description>Advanced katas for javascripters</description>
	<lastBuildDate>Fri, 30 Jul 2010 18:10:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: jQuery &#8211; 當Javascript Ajax遇上Loop &#124; 亞特蘭提斯 Net Atlantis</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-846</link>
		<dc:creator>jQuery &#8211; 當Javascript Ajax遇上Loop &#124; 亞特蘭提斯 Net Atlantis</dc:creator>
		<pubDate>Fri, 06 Nov 2009 17:00:31 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-846</guid>
		<description>[...] 運行程式後,得出的alert不是順序的12345678910，有可能是4231789&#8230;或者9714523。當然把async設成false就可以解決問題，但是運行時，Browser會呈現硬直狀態。 解決方法雖然是找到了，但是為什麼會這樣? 可以睇睇國外高手的Blog文: Ajax and javascript don’t use threads Ajax, javascript and threads : the final truth [...]</description>
		<content:encoded><![CDATA[<p>[...] 運行程式後,得出的alert不是順序的12345678910，有可能是4231789&#8230;或者9714523。當然把async設成false就可以解決問題，但是運行時，Browser會呈現硬直狀態。 解決方法雖然是找到了，但是為什麼會這樣? 可以睇睇國外高手的Blog文: Ajax and javascript don’t use threads Ajax, javascript and threads : the final truth [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BK</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-332</link>
		<dc:creator>BK</dc:creator>
		<pubDate>Tue, 03 Jul 2007 20:00:06 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-332</guid>
		<description>No matter if it always happen, sometimes happen or never happen, the best thing for a piece of code to never break is to try to anticipate all cases.

In this particular situation, all cases implies may different browsers, each with their own implementations, built in different &quot;computer eras&quot;, that are still evolving and mostly within a language that is actually in a major second life.</description>
		<content:encoded><![CDATA[<p>No matter if it always happen, sometimes happen or never happen, the best thing for a piece of code to never break is to try to anticipate all cases.</p>
<p>In this particular situation, all cases implies may different browsers, each with their own implementations, built in different &#8220;computer eras&#8221;, that are still evolving and mostly within a language that is actually in a major second life.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Galligan</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-331</link>
		<dc:creator>Kevin Galligan</dc:creator>
		<pubDate>Thu, 28 Jun 2007 18:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-331</guid>
		<description>&quot;never expect some code to run before or after another&quot;

That&#039;s not exactly true, though.  Right?  Yeah, if you have &#039;alert&#039; or &#039;confirm&#039; in there, one browser might let other methods run, and another won&#039;t, but without calling those, your ajax callbacks aren&#039;t run until your other javascript is done.  Right?  We have a case where this is critical.  If its not true, I need to implement a queue method calling mechanism, which isn&#039;t the end of the world, but isn&#039;t fun either.</description>
		<content:encoded><![CDATA[<p>&#8220;never expect some code to run before or after another&#8221;</p>
<p>That&#8217;s not exactly true, though.  Right?  Yeah, if you have &#8216;alert&#8217; or &#8216;confirm&#8217; in there, one browser might let other methods run, and another won&#8217;t, but without calling those, your ajax callbacks aren&#8217;t run until your other javascript is done.  Right?  We have a case where this is critical.  If its not true, I need to implement a queue method calling mechanism, which isn&#8217;t the end of the world, but isn&#8217;t fun either.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FlameBot</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-330</link>
		<dc:creator>FlameBot</dc:creator>
		<pubDate>Sun, 24 Jun 2007 16:37:21 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-330</guid>
		<description>Hey, why don&#039;t you all just read the browsers&#039; source code to find out how the threading model is done?

Oh, right...</description>
		<content:encoded><![CDATA[<p>Hey, why don&#8217;t you all just read the browsers&#8217; source code to find out how the threading model is done?</p>
<p>Oh, right&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alon Weiss</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-329</link>
		<dc:creator>Alon Weiss</dc:creator>
		<pubDate>Mon, 18 Jun 2007 15:52:09 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-329</guid>
		<description>Silverlight supports running JScript natively, WITH threading support. Shouldn&#039;t take too long to compile an example out of this.
I wonder if we can build a wrapper that will get a string that will be eval&#039;d at another thread, with another object as an execution context and another one as a parameter list.</description>
		<content:encoded><![CDATA[<p>Silverlight supports running JScript natively, WITH threading support. Shouldn&#8217;t take too long to compile an example out of this.<br />
I wonder if we can build a wrapper that will get a string that will be eval&#8217;d at another thread, with another object as an execution context and another one as a parameter list.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrey</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-328</link>
		<dc:creator>Andrey</dc:creator>
		<pubDate>Mon, 18 Jun 2007 11:33:25 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-328</guid>
		<description>@BK: &quot;By design, any asynchronous call, somewhere, generates a new thread. There is no other way to do this (if you know one, please tell me).&quot;

Browser has a pool of threads doing all download jobs (pages,images,css,js and any other files, _including_ ajax calls). Calling new XHR just schedules new job to this pool. On return this task &#039;injects&#039; callback address in the queque of waiting tasks of &#039;cooperative multitasking&#039; roundrobin of JavaScript evaluator.

Btw, read about &#039;completion ports&#039; and &#039;fibers&#039; - these are used in the Firefox NSPR runtime.</description>
		<content:encoded><![CDATA[<p>@BK: &#8220;By design, any asynchronous call, somewhere, generates a new thread. There is no other way to do this (if you know one, please tell me).&#8221;</p>
<p>Browser has a pool of threads doing all download jobs (pages,images,css,js and any other files, _including_ ajax calls). Calling new XHR just schedules new job to this pool. On return this task &#8216;injects&#8217; callback address in the queque of waiting tasks of &#8216;cooperative multitasking&#8217; roundrobin of JavaScript evaluator.</p>
<p>Btw, read about &#8216;completion ports&#8217; and &#8216;fibers&#8217; &#8211; these are used in the Firefox NSPR runtime.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Calvin Spealman</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-327</link>
		<dc:creator>Calvin Spealman</dc:creator>
		<pubDate>Sat, 16 Jun 2007 04:20:36 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-327</guid>
		<description>I actually thought this was already a known fact. I suppose if anyone is doubtful, having a test to show the reality of it is a good thing.</description>
		<content:encoded><![CDATA[<p>I actually thought this was already a known fact. I suppose if anyone is doubtful, having a test to show the reality of it is a good thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BK</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-326</link>
		<dc:creator>BK</dc:creator>
		<pubDate>Fri, 15 Jun 2007 11:36:19 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-326</guid>
		<description>By design, any asynchronous call, somewhere, generates a new thread. There is no other way to do this (if you know one, please tell me). BUT, on the other hand, since JS itself is single threaded, any request coming from an async thread is queued in a call queue.

About the fact that &quot;The documentation of XMLHTTPRequest (et al) clearly states that the process waits for the return of the Ajax â€œrequestâ€ or a timeout&quot; could you give your reference? I&#039;m quite curious to see this on the MS site about the &quot;async&quot; call because then, what would be the difference with the synchronous call. This sound a bit absurd.</description>
		<content:encoded><![CDATA[<p>By design, any asynchronous call, somewhere, generates a new thread. There is no other way to do this (if you know one, please tell me). BUT, on the other hand, since JS itself is single threaded, any request coming from an async thread is queued in a call queue.</p>
<p>About the fact that &#8220;The documentation of XMLHTTPRequest (et al) clearly states that the process waits for the return of the Ajax â€œrequestâ€ or a timeout&#8221; could you give your reference? I&#8217;m quite curious to see this on the MS site about the &#8220;async&#8221; call because then, what would be the difference with the synchronous call. This sound a bit absurd.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Griffiths</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-325</link>
		<dc:creator>Mike Griffiths</dc:creator>
		<pubDate>Fri, 15 Jun 2007 10:49:05 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-325</guid>
		<description>Why did anyone think that JavaScript was executed in multiple threads by the browsers? The documentation of XMLHTTPRequest (et al) clearly states that the process waits for the return of the Ajax &quot;request&quot; or a timeout.

The new Google Gears beta includes provision for the execution of multiple JavaScript threads - check it out as this was probably the most important component of the Google Gears &quot;package&quot;.</description>
		<content:encoded><![CDATA[<p>Why did anyone think that JavaScript was executed in multiple threads by the browsers? The documentation of XMLHTTPRequest (et al) clearly states that the process waits for the return of the Ajax &#8220;request&#8221; or a timeout.</p>
<p>The new Google Gears beta includes provision for the execution of multiple JavaScript threads &#8211; check it out as this was probably the most important component of the Google Gears &#8220;package&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.javascriptkata.com/2007/06/12/ajax-javascript-and-threads-the-final-truth/comment-page-1/#comment-324</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Fri, 15 Jun 2007 02:43:10 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=47#comment-324</guid>
		<description>I hacked at this for an hour and have arrived at the same conclusion - javascript just doesn&#039;t do threads.</description>
		<content:encoded><![CDATA[<p>I hacked at this for an hour and have arrived at the same conclusion &#8211; javascript just doesn&#8217;t do threads.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
