Ok, I'll rephrase. There are no threads in javascript itself and in browsers implementations. Chunks of code runs synchronously one-by-one. setTimeout just change it's ordering. You can look for Nicholasz presentation (don't remember how it called exactly) where he shows example with sorting big amount of data and drag divs in the same time. Problem solved with setTimeout. But i prefer to use word "emulation" when explaining JS to server side guys, it's easy for them to understand :)
Anton. On Dec 17, 2010, at 5:51 AM, Yu-Hsuan Lai wrote: > Uh... I guessed it use setTimeout, but I read this: > http://ejohn.org/blog/how-javascript-timers-work/ > SetTimeout seems can't emulate threads, it really confuse me. > > On Fri, Dec 17, 2010 at 11:41 AM, Anton Yacenko <[email protected]> > wrote: > It's implemented with setTimeout. > setTimeout is not a part of ECMA specification. > It's basically a trick, that implemented in browsers, so it's our "threads" > emulation :) > > Anton. > > On Dec 17, 2010, at 5:33 AM, Yu-Hsuan Lai wrote: > >> Thanks for the resources.( though my listening skill is not enough to >> understand the speech...) >> >> Another question: >> If I have two jquery.animation like below: >> $(".div1").animate({width:10},"slow"); >> $(".div2").animate({width:1000},"slow"); >> div1 and div2 will change their width "synchronously", but doesn't >> javascript have only one thread? >> How do jquery implement it? >> >> On Fri, Dec 17, 2010 at 10:32 AM, Chris Williams <[email protected]> wrote: >> >> There are various advantages (simplicity, comprehensibility, flexibility) >> that single threaded, evented models have over multi-threaded paradigm. The >> biggest argument is that threading is hard and not many people actually know >> how to do it properly. >> >> >> Brendan Eich (creator of JS) spoken on this in November, give it a listen: >> http://www.aminutewithbrendan.com/pages/20101108 >> >> -- >> Chris Williams >> >> Twitter: http://twitter.com/voodootikigod >> OurParents: http://ourparents.com >> JSConf US: http://jsconf.us >> Minute With: http://minutewith.com >> >> On Thursday, December 16, 2010 at 9:31 PM, Chris Williams wrote: >> >>> >>> There are various advantages (simplicity, comprehensibility, flexibility) >>> that single threaded, evented models have over multi-threaded paradigm. The >>> biggest argument is that threading is hard and not many people actually >>> know how to do it properly. >>> >>> Brendan Eich (creator of JS) spoken on this in November, give it a listen: >>> http://www.aminutewithbrendan.com/pages/20101108 >>> >>> -- >>> Chris Williams >>> >>> Twitter: http://twitter.com/voodootikigod >>> OurParents: http://ourparents.com >>> JSConf US: http://jsconf.us >>> Minute With: http://minutewith.com >>> >>> On Thursday, December 16, 2010 at 9:25 PM, Yu-Hsuan Lai wrote: >>> >>>> Javascript is a functional language, it's proper to design thread-safe >>>> program. >>>> And most modern language can support multi-threading programming. >>>> It's just a legacy? Or single thread has some advantages for javascript? >>>> >>>> -- >>>> Lai, Yu-Hsuan >>>> >>>> -- >>>> To view archived discussions from the original JSMentors Mailman list: >>>> http://www.mail-archive.com/[email protected]/ >>>> >>>> To search via a non-Google archive, visit here: >>>> http://www.mail-archive.com/[email protected]/ >>>> >>>> To unsubscribe from this group, send email to >>>> [email protected] >>> >> >> >> -- >> To view archived discussions from the original JSMentors Mailman list: >> http://www.mail-archive.com/[email protected]/ >> >> To search via a non-Google archive, visit here: >> http://www.mail-archive.com/[email protected]/ >> >> To unsubscribe from this group, send email to >> [email protected] >> >> >> >> -- >> Lai, Yu-Hsuan >> >> -- >> To view archived discussions from the original JSMentors Mailman list: >> http://www.mail-archive.com/[email protected]/ >> >> To search via a non-Google archive, visit here: >> http://www.mail-archive.com/[email protected]/ >> >> To unsubscribe from this group, send email to >> [email protected] > > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > > > > -- > Lai, Yu-Hsuan > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
