473,805 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is JavaScript guaranteed to be single threaded?

Hi,

I use a lot asynchronous XMLHTTP from JavaScript. Are the callbacks
that we register with XMLHTTP guaranteed to execute single-threaded?
For instance, consider the following code snippet.

var xmlhttp1 = new ActiveXObject( "Msxml2.XMLHTTP .4.0" );
xmlhttp1.onread ystatechange = callback;
xmlhttp1.open( "POST", "foo.aspx", true );
xmlhttp1.send( data1 );

var xmlhttp2 = new ActiveXObject( "Msxml2.XMLHTTP .4.0" );
xmlhttp2.onread ystatechange = callback;
xmlhttp2.open( "POST", "foo.aspx", true );
xmlhttp2.send( data2 );

function callback()
{
//
// will two instances of this function run
// parallely?
//
}

Will the function "callback" be run parallelly should both the XMLHTTP
requests return simultaneously? Or does IE somehow serialize calls to
the callback routine? Its important for me that the callback executes
single threaded since things like critical sections aren't possible in
JavaScript.

Thanks.

--
Ranju. V
http://www.geocities.com/cool_ranju/

Jul 23 '05 #1
5 2531
In article <10************ **********@f14g 2000cwb.googleg roups.com>,
Ranju. V <av*****@gmail. com> writes
Hi,

I use a lot asynchronous XMLHTTP from JavaScript. Are the callbacks
that we register with XMLHTTP guaranteed to execute single-threaded?

<snip>

Guaranteed. Software.

You don't often see those two words in the same sentence.

John
--
John Harris
Jul 23 '05 #2
> >
I use a lot asynchronous XMLHTTP from JavaScript. Are the callbacks
that we register with XMLHTTP guaranteed to execute single-threaded?

<snip>

Guaranteed. Software.
You don't often see those two words in the same sentence.


Thanks. That's a relief. And yes, those two words aren't really the
best of pals!

--
Ranju. V
http://www.geocities.com/cool_ranju/

Jul 23 '05 #3
In article <10************ **********@c13g 2000cwb.googleg roups.com>,
Ranju. V <av*****@gmail. com> writes
>
>I use a lot asynchronous XMLHTTP from JavaScript. Are the callbacks
>that we register with XMLHTTP guaranteed to execute single-threaded?

<snip>

Guaranteed. Software.
You don't often see those two words in the same sentence.


Thanks. That's a relief. And yes, those two words aren't really the
best of pals!


I'm afraid I said it in a misleading way. I'm suggesting that software
companies seldom make guarantees. Even when they do they aren't always
telling the truth :-(

John
--
John Harris
Jul 23 '05 #4
On 4 Nov 2004 01:42:39 -0800, "Ranju. V" <av*****@gmail. com> wrote:
I use a lot asynchronous XMLHTTP from JavaScript. Are the callbacks
that we register with XMLHTTP guaranteed to execute single-threaded?
For instance, consider the following code snippet.


Yes, they are single threaded in all implementations .

(of course in your example there's no guarantee that the callback of
the xmlhttp1 be called before the callback of xmlhttp2, but they will
not be called simultaneously. )

Jim.
Jul 23 '05 #5
> I'm afraid I said it in a misleading way. I'm suggesting that
software
companies seldom make guarantees. Even when they do they aren't always telling the truth :-(


True enough. I mean does anybody ever read the license agreements that
software installation programs make the user agree to? If you spend a
little time and actually read one of those agreements then you'll find
that they pretty much devolve themselves of all responsibility should
something go wrong!

--
Ranju. V
http://www.geocities.com/cool_ranju/

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2006
by: Robb Gilmore | last post by:
We inherited an ASP.NET application which is not thread-safe. Many copies of this application are in the field and customers are having problems, which we believe is due to the thread safety problem. Is there any way to configure IIS to run single-threaded, so that these customers can get along without errors until we can get them updated software? Some will have IIS 5.0 ( Win2K and WinXP ) and some will have IIS 6.0 ( Win03 ). For...
3
1605
by: Martin Ink | last post by:
I have a program linked to an .exe and this program is started from an other program. I would like to control the execution of the program so that the program only runs 'single threaded'. I don't want simultaneously session of my program to be run. My program must be an .exe. Is there a way to control this in a simple way ?? Rgds
136
9468
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
7
2173
by: dm | last post by:
Hi, I'd like to know if the C standard can guarantee that an assignment to/from a variable will be atomic, that is will occur in a single indivisible instruction. For example, if I have the following code: int global_var;
2
1711
by: Rob | last post by:
Hi. I'm having difficulty calling a 3rd party COM object that must be called in the apartment (single) threaded model. As far as I know, there are 3 ways todo this: 1 - use "aspcompat=true" for aspx pages 2 - use attribute for windows/console applications 3 - use System.Thread.CurrentThread.ApartmentState = ApartmentState.STA
6
4964
by: ben | last post by:
I am needing a web service to be single threaded. Is this possible? Any ideas would be helpful
2
5740
by: Penguin | last post by:
Hi All, I would like to use thread in javascript how to do that? like in java to implement Runable or extends Thread class. could you show a snippet of code? thanks and regards, ralph
3
1926
by: NeoAlchemy | last post by:
If JavaScript is single threaded, what is happening if I have two ajax calls executed around the same time. and they come back and hit two different callbacks. Would the callback functions execute at the same time together. Would one take precedence over the other?
11
1736
by: Chris Thomasson | last post by:
Here is the code: http://pastebin.com/m4a405e67 One advantage to using a region allocator is that you can usually skip most calls to free. Instead you can merge multiple free calls into a single reset call. Here is simple example: ___________________________________________________________________
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.