Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   web worker threads and window.settimeout (http://www.velocityreviews.com/forums/t938970-web-worker-threads-and-window-settimeout.html)

wolverine 07-01-2009 11:34 AM

web worker threads and window.settimeout
 
Hi Friends,

Today I was reading about web worker threads at
https://developer.mozilla.org/En/Using_DOM_workers supported by
Firefox 3.5. They allow web content to run in background in different
threads. But isn't that the same facility(in a roundabout way)
provided by 'settimeout' function. window.settimeout also allows us to
execute a function in background threads with affecting UI. So why do
Firefox folks had to go for web worker threads supports if the only
thing they wanted was to do jobs in background.

Thanks for Reading,
Kiran.

Martin Honnen 07-01-2009 11:38 AM

Re: web worker threads and window.settimeout
 
wolverine wrote:

> Today I was reading about web worker threads at
> https://developer.mozilla.org/En/Using_DOM_workers supported by
> Firefox 3.5. They allow web content to run in background in different
> threads. But isn't that the same facility(in a roundabout way)
> provided by 'settimeout' function. window.settimeout also allows us to
> execute a function in background threads with affecting UI. So why do
> Firefox folks had to go for web worker threads supports if the only
> thing they wanted was to do jobs in background.


setTimeout simply sets up a timer to run some code after a specified
time. That code runs in the same thread as the code calling setTimeout.
So there is no use of different threads with setTimeout.



--

Martin Honnen
http://msmvps.com/blogs/martin_honnen/

Jorge 07-01-2009 12:17 PM

Re: web worker threads and window.settimeout
 
On Jul 1, 1:34*pm, wolverine <kiran.ha...@gmail.com> wrote:
> Hi Friends,
>
> Today I was reading about web worker threads athttps://developer.mozilla.org/En/Using_DOM_workerssupported by
> Firefox 3.5. They allow web content to run in background in different
> threads. But isn't that the same facility(in a roundabout way)
> provided by 'settimeout' function. window.settimeout also allows us to
> execute a function in background threads with affecting UI. So why do
> Firefox folks had to go for web worker threads supports if the only
> thing they wanted was to do jobs in background.


workers are separate JS processes () running in separate threads,
workers execute concurrently,
workers don't block the UI,
workers allow you to extract up to the last drop of juice from a
multicore cpu,
workers can be dedicated (single tab) or shared among tabs/windows,
workers can be persistent too (coming soon): they'll keep running
after the browser has quit.

See "Google I/O 2009 - Google's HTML 5 Work: What's Next?":
<http://www.youtube.com/watch?v=AusOPz8Ww80>
starting @0h:13m:56s
--
Jorge.

wolverine 07-02-2009 08:33 AM

Re: web worker threads and window.settimeout
 
On Jul 1, 4:38*pm, Martin Honnen <mahotr...@yahoo.de> wrote:
> wolverine wrote:
> > Today I was reading about web worker threads at
> >https://developer.mozilla.org/En/Usi...rkerssupported by
> > Firefox 3.5. They allow web content to run in background in different
> > threads. But isn't that the same facility(in a roundabout way)
> > provided by 'settimeout' function. window.settimeout also allows us to
> > execute a function in background threads with affecting UI. So why do
> > Firefox folks had to go for web worker threads supports if the only
> > thing they wanted was to do jobs in background.

>
> setTimeout simply sets up a timer to run some code after a specified
> time. That code runs in the same thread as the code calling setTimeout.
> So there is no use of different threads with setTimeout.
>
> --
>
> * * * * Martin Honnen
> * * * *http://msmvps.com/blogs/martin_honnen/


Thanks a lot for your reply Martin. Since the code is always going to
run in the main thread, does this mean that there is no gain in
performance or UI responsiveness obtained by running a code with
setTimeout ? I already read your post on a similar topic at
http://groups.google.com/group/comp....24fcf63dd1869e.
I assume even the use of setTimeout will result in UI getting blocked
at a later point of time.

wolverine 07-02-2009 08:39 AM

Re: web worker threads and window.settimeout
 
On Jul 1, 5:17*pm, Jorge <jo...@jorgechamorro.com> wrote:
> On Jul 1, 1:34*pm, wolverine <kiran.ha...@gmail.com> wrote:
>
> > Hi Friends,

>
> > Today I was reading about web worker threads athttps://developer.mozilla.org/En/Using_DOM_workerssupportedby
> > Firefox 3.5. They allow web content to run in background in different
> > threads. But isn't that the same facility(in a roundabout way)
> > provided by 'settimeout' function. window.settimeout also allows us to
> > execute a function in background threads with affecting UI. So why do
> > Firefox folks had to go for web worker threads supports if the only
> > thing they wanted was to do jobs in background.

>
> workers are separate JS processes () running in separate threads,
> workers execute concurrently,
> workers don't block the UI,
> workers allow you to extract up to the last drop of juice from a
> multicore cpu,
> workers can be dedicated (single tab) or shared among tabs/windows,
> workers can be persistent too (coming soon): they'll keep running
> after the browser has quit.
>
> See "Google I/O 2009 - Google's HTML 5 Work: What's Next?":
> <http://www.youtube.com/watch?v=AusOPz8Ww80>
> starting @0h:13m:56s
> --
> Jorge.


Jorge, That really helped. I was also reading an incomplete discussion
involving you on the muticore cpu.
http://groups.google.com/group/comp....24fcf63dd1869e.


All times are GMT. The time now is 12:37 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.