web worker threads and window.settimeout

Discussion in 'Javascript' started by wolverine, Jul 1, 2009.

  1. wolverine

    wolverine Guest

    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.
     
    wolverine, Jul 1, 2009
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Jul 1, 2009
    #2
    1. Advertising

  3. wolverine

    Jorge Guest

    On Jul 1, 1:34 pm, wolverine <> 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.
     
    Jorge, Jul 1, 2009
    #3
  4. wolverine

    wolverine Guest

    On Jul 1, 4:38 pm, Martin Honnen <> wrote:
    > wolverine wrote:
    > > Today I was reading about web worker threads at
    > >https://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.

    >
    > 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...unning too long, what to do?#0424fcf63dd1869e.
    I assume even the use of setTimeout will result in UI getting blocked
    at a later point of time.
     
    wolverine, Jul 2, 2009
    #4
  5. wolverine

    wolverine Guest

    On Jul 1, 5:17 pm, Jorge <> wrote:
    > On Jul 1, 1:34 pm, wolverine <> 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...unning too long, what to do?#0424fcf63dd1869e.
     
    wolverine, Jul 2, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. alex
    Replies:
    1
    Views:
    693
    Lau Lei Cheong
    Feb 4, 2005
  2. Replies:
    4
    Views:
    1,339
  3. fooooo
    Replies:
    5
    Views:
    957
    Paul Rubin
    May 3, 2005
  4. Jp Calderone
    Replies:
    1
    Views:
    1,379
    Paul Rubin
    May 24, 2005
  5. Jon Pope

    Worker threads on a webservice?

    Jon Pope, Jan 16, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    225
    Jon Pope
    Jan 16, 2007
Loading...

Share This Page