Android developer advice:
The network is especially slow and inconsistent, so you should never do network requests on your main thread. In fact, in the upcoming Honeycomb release we’ve made network requests on the main thread a fatal error, unless your app is targeting an API version before Honeycomb. So if you want to get ready for the Honeycomb SDK, make sure you’re never doing network requests on your UI thread.
Network requests can (should!) be handled with asynchrony, and asynchrony can (should?) be handled without introducing threads (event/message loops). What they’re saying is that it’s not just okay to sit around spinning for network, you actually have to involve a new thread, on a device with scarce resources, just to do that, even if you’re just doing it asynchronously. That’s conceptual and actual overhead.
As long as you start the request asynchronously, it doesn’t really matter what happens. Even if network requests did involve the CPU sitting around spinning, the system should be able to do that in a special thread for you. With the way it actually works, the CPU sets off the request and the networking interface and the network does most of the busywork until you start to get stuff back and the buffers fill. You yield immediately for other stuff, and the asynchronous operation picks up when it’s done.
I’d like to hear from any Android developers whether there’s any architectural reason to actually do a new thread. Conventional wisdom and past experience, including several operating systems with millions of users, says you don’t have to do it. Are there any constraints I’m missing, or is it that the APIs (or Java itself) are so inept that most people can’t bother getting asynchrony right anyway?