1 Reply Latest reply on Apr 14, 2010 3:30 AM by Matt Le Fevre

    HTTPService multithreading?

    hidarikani Level 2

      What happens when I do this:

       

       

      myHttpService.send() //send 1
      myHttpService.send() //send 2
      
      
      

       

       

      Are send 1 and send 2 executed at the same time (multithreading) or are they stacked and executed one at a time?

       

      I have 10 objects which share one HTTPService instance, will I speed up the app if I give each object a different HTTPService instance?

        • 1. Re: HTTPService multithreading?
          Matt Le Fevre Level 4

          hidarikani wrote:

           

          What happens when I do this:

           

           

          myHttpService.send() //send 1
          myHttpService.send() //send 2
          
          
          

           

           

          Are send 1 and send 2 executed at the same time (multithreading) or are they stacked and executed one at a time?

           

          I have 10 objects which share one HTTPService instance, will I speed up the app if I give each object a different HTTPService instance?

           

          as far as i'm aware, they'll be sent in sequential order, but their result events won't necessarily be in the same order, depending on how long each of them take to complete.

           

           

          as far as how you should organise them, that depends on what data you're retriveing with them. Does you need to have certain information readily returned from one of them before you send off another Service? Or are they totally independant of each other?

           

          you could simply just do

           

          myHttpService1.send()

          myHttpService2.send()

          myHttpService3.send()

          etc..

           

          all in the same function if none of them rely on each other.

           

          Although, personally i find that very messy and have adopted sending the next service on the result of the previous one, for example

           

          private function init():void

          {

               HttpService1.send()

          }

           

          private function HttpService1_result(event:ResultEvent):void

          {

               HttpService2.send()

          }

           

          private function HttpService2_result(event:ResultEvent):void

          {

               HttpService3.send()

          }

           

          etc...

           

          it's far more organised, and keeps things happening as you would expect. It'll be abit slower however, as it requires each service to complete before requesting the next.

           

           

          If you're looking to save time, send them all at once. But like i said, make sure, for example, service #8 doesn't rely on #6 having been completed before it's sent.

          1 person found this helpful