6. Given the equation in $x$
$$
x^{3}-4 x^{2}+5 x+a=0(a \in \mathbf{R})
$$

has three real roots $x_{1}, x_{2}, x_{3}$. Then the maximum value of $\max \left\{x_{1}, x_{2}, x_{3}\right\}$ is $\qquad$ .
6.2.

Assume $x_{3}=\max \left\{x_{1}, x_{2}, x_{3}\right\}$.
By Vieta's formulas, we have
$$
\begin{array}{l}
\left\{\begin{array}{l}
x_{1}+x_{2}+x_{3}=4, \\
x_{1} x_{2}+x_{2} x_{3}+x_{3} x_{1}=5
\end{array}\right. \\
\Rightarrow\left\{\begin{array}{l}
x_{1}+x_{2}=4-x_{3}, \\
x_{1} x_{2}=5-x_{3}\left(x_{1}+x_{2}\right)=5-x_{3}\left(4-x_{3}\right) .
\end{array}\right.
\end{array}
$$

Thus, the quadratic equation with roots $x_{1} 、 x_{2}$ is
$$
\begin{array}{l}
x^{2}-\left(4-x_{3}\right) x-5+x_{3}\left(4-x_{3}\right)=0 \\
\Rightarrow \Delta=\left(4-x_{3}\right)^{2}-4\left[5-x_{3}\left(4-x_{3}\right)\right] \geqslant 0 \\
\Rightarrow 3 x_{3}^{2}-8 x_{3}+4 \leqslant 0 \\
\Rightarrow \frac{2}{3} \leqslant x_{3} \leqslant 2 .
\end{array}
$$

When $x_{3}=2$, $x_{1}=x_{2}=1, a=-2$.
Therefore, the maximum value of $\max \left\{x_{1}, x_{2}, x_{3}\right\}$ is 2.