A simple example is
double d = Double.NaN; // or
double d = 0.0/0.0; // or
double d = Double.POSITIVE_INFINITY + Double.NEGATIVE_INFINITY;
if (Double.isNaN(a)) { // tests if a != a
// do something
BTW Double.compare() does see NaN as equal
if (Double.compare(d, d) == 0) // always.
With multiple threads this is possible for any type and value. e.g.
if (a != /* another thread changes 'a' */ a) {
// a thread changed a while you were looking at it.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…