There are very few applications that can run in the background. Mail and SMS works in the background, but everything else it task-switched. If you run a game of solitaire and quit it, it's state will have been saved to the application's sandbox meaning it picks up when you reload it. However, if you're running AIM and you go off to do an email or browse a webpage, you will be disconnected from AIM.
This may sound bad, but this is how the iPhone has the best battery-life of all the 3G smartphones, although it's still not as good as we'd like.