Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > threads in browser javascript

Reply
Thread Tools

threads in browser javascript

 
 
dd
Guest
Posts: n/a
 
      02-01-2007
Whenever anyone asks me, I've always said there are no
threads in browser JavaScript. I heard Douglas Crockford
say it last week in his Yahoo lecture too. I've always been
not too worried about reentrancy and being threadsafe in
general.

Weirdly though, one day I was debugging in Visual Studio
and was halfway through a particular function that had been
called by some inline code or user click.

At a certain point while stepping through, some other event
(which had that same function assigned to it) resulted in a
threaded call to that same function. I then found myself
stepping through this event-triggered call right through to
the end. When I executed the final } I then found myself
returning back to my original position in that function, where
I was before the event.

So although there aren't parallel threads running, it appears
that script execution can be interrupted. It is therefore
important to make sure that a function that makes use of
globals would need to consider that at any time an event
may occur, and the handler function for that array would be
able to change those globals.

I think setInterval and setTimeout are not sufficiently privileged
to interrupt a script path. I suspect that the current function
chain/sequence would complete first before the set* gets a
look in.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Threads - Get running threads Pedro Pinto Java 2 04-08-2008 11:44 PM
[new to threads] threads with UI and loop Une bévue Ruby 0 06-14-2006 10:22 AM
TB View, Threads, Threads with unread The Invisible Man Firefox 1 03-20-2006 02:09 AM
Standard Threads vs Weightless Threads yoda Python 2 08-01-2005 09:12 PM
threads without threads sindica@gmail.com C Programming 4 08-27-2004 09:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57