Example 2 defines the length of intervals $(c, d)$, $[c, d)$, $(c, d]$, and $[c, d]$ as $d-c$ ($d>c$). Given real numbers $a$, $b$ ($a>b$). The sum of the lengths of the intervals formed by $x$ that satisfy $\frac{1}{x-a}+\frac{1}{x-b} \geqslant 1$ is ( ).
(A) 1
(B) $a-b$
(C) $a+b$
(D) 2
(2007, National High School Mathematics League Tianjin Preliminary Contest)
Notice that
$$
\begin{array}{l}
\frac{1}{x-a}+\frac{1}{x-b} \geqslant 1 \\
\Leftrightarrow \frac{2 x-(a+b)}{(x-a)(x-b)} \geqslant 1 \\
\Leftrightarrow \frac{(x-a)(x-b)+a+b-2 x}{(x-a)(x-b)} \leqslant 0 .
\end{array}
$$

Let $g(x)=(x-a)(x-b)+a+b-2 x$
$$
=x^{2}-(a+b+2) x+a b+a+b \text {. }
$$

Notice that
$$
g(a)=b-a<0 .
$$

Then $g(x)=0$ has two distinct real roots. Let them be $x_{1} 、 x_{2}\left(x_{1}<x_{2}\right)$. Thus,
$$
\begin{array}{l}
x_{1}+x_{2}=a+b+2, \\
b<x_{1}<a<x_{2} .
\end{array}
$$

Therefore, $g(x)=\left(x-x_{1}\right)\left(x-x_{2}\right)$.
Hence, (1) $\Leftrightarrow \frac{\left(x-x_{1}\right)\left(x-x_{2}\right)}{(x-a)(x-b)} \leqslant 0$.
Thus, the solution to the inequality is $\left(b, x_{1}\right] \cup\left(a, x_{2}\right]$.
The sum of the lengths of the solution intervals is
$$
\begin{array}{l}
x_{1}-b+x_{2}-a \\
=\left(x_{1}+x_{2}\right)-(a+b) \\
=(a+b+2)-(a+b)=2 .
\end{array}
$$