Welcome to the world of asynchrony!






Welcome to the world of asynchrony!

It's been a long ride, but you should have everything in place to get your co-workers all the caffeine they want, without any waiting. Be sure you've made the changes to ajax.js and coffee.js so that there are two request objects used: one for each coffee maker.

Place coffee orders for Jim and Bob, and get both coffee makers brewing.

Jim's order comes back ready from the first coffee maker...

...and Bob's order comes back from the second coffee maker!

That's all fine, but I want to see what happens in this application when it's not asynchronous. I want to compare the synchronous and asynchronous versions, and see if the asynchronous version is really that much better.

Skeptical?

So, you want to see for yourself how different the Coffee Maker program is as a synchronous application? That's easy to do. All you have to do is change the third argument of the call to request.open() in the sendRequest() function: switch it from true to false:

    function sendRequest(request, url) {
      request.onreadystatechange = serveDrink;
      request.open("GET", url, false);Change the argument
      from true to false to tell your application to send the request to the
      coffee makers on the server synchronously.
      Then give it a try. What happens?
      request.send(null);
    }



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows