Connecting Tech Pros Worldwide Help | Site Map

How to use Thread in javascript

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 18th, 2006, 12:35 AM
Penguin
Guest
 
Posts: n/a
Default How to use Thread in javascript

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


  #2  
Old July 18th, 2006, 03:15 AM
RobG
Guest
 
Posts: n/a
Default Re: How to use Thread in javascript

Penguin wrote:
Quote:
Hi All,
>
I would like to use thread in javascript how to do that?
Execute some code - there is only one thread, so whatever runs uses it.

Quote:
like in java to implement Runable or extends Thread class.
Only one thread, no classes. You can use setTimeout or setInterval to
make things happen other than synchronously, but never in another
thread.

I guess some implementations of JavaScript could be multi-threaded, but
there is nothing in the ECMAScript specification to let you manage
them. So if some UA somewhere does have a multi-threaded script
environment, from a programmers' viewpoint, it's single threaded unless
it also has non-standard extensions to manage them.

Quote:
could you show a snippet of code?
function funcA() { /* ...do lots of stuff...*/ }
function funcB() { /* ...do very little stuff...*/ }

funcA();
funcB();

funcA will always finish before funcB is called. :-)


--
Rob

  #3  
Old July 18th, 2006, 01:15 PM
Julian Turner
Guest
 
Posts: n/a
Default Re: How to use Thread in javascript


Penguin wrote:
Quote:
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
The only way I have managed to "emulate" a separate thread (only tested
in IE) is to open a separate pop-up window. That separate pop-up
window seems to run in its own thread, and I have managed to create
progress bars by doing this which can receive instructions from a
running function in the parent window and update simultaneously.

Regards

Julian

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.