TITLE: When can we exchange order of two limits?
QUESTION [23 upvotes]: My questions are about a sequence or function with several variables. 

I vaguely remember some while ago one
of my teachers said taking limits of
a sequence or function with respect to
different variables is not
exchangeable everywhere, i.e.
$$ \lim_n \lim_m a_{n,m} \neq \lim_m \lim_n a_{n,m}, \quad \lim_x \lim_y f(x,y) \neq \lim_y \lim_x f(x,y).$$
So my
question is what are the cases or
examples when one can exchange the
order of taking limits and when one
cannot, to your knowledge? I would
like to collect the cases together,
and be aware of their difference and
avoid making mistakes. If you could
provide some general guidelines, that
will be even nicer!
To give you an example of what I am
asking about, this is a question that
confuses me: Assume $f: [0, \infty)
   \rightarrow (0, \infty)$ is a
function, satisfying $$
   \int_0^{\infty} x f(x) \, dx < \infty.
   $$ Determine the convergence of this
series $\sum_{n=1}^{\infty}
   \int_n^{\infty} f(x) dx$.
The answer I saw is to exchange the
order of $\sum_{n=1}^{\infty}$ and
$\int_n^{\infty}$ as follows: $$
   \sum_{n=1}^{\infty} \int_n^{\infty}
   f(x) dx
   = \int_1^{\infty} \sum_{n=1}^{\lfloor x \rfloor}  f(n) dx \leq
   \int_1^{\infty} \lfloor x \rfloor 
   f(x) dx $$ where $\lfloor x \rfloor$
is the greatest integer less than
$x$. In this way, the answer proves the series converges. I was wondering why the two steps are valid? Is there some special meaning of the first equality? Because it looks similar to the tail sum formula for expectation of a random variable $X$ with possible values $\{ 0,1,2,...,n\}$: $$\sum_{i=0}^n i P(X=i) = \sum_{i=0}^n P(X\geq i).$$ The formula is from Page 171 of Probability by Jim Pitman, 1993. Are they really related?

Really appreciate your help!

REPLY [2 votes]: $f(x,y)=\frac{x-y}{x+y}.$
You can also check the limit at the point $(0,0)$. Typical example of calculus.