Here you can find the source of addThrowable(AtomicReferenceFieldUpdater
public static <T> boolean addThrowable(AtomicReferenceFieldUpdater<T, Throwable> field, T instance, Throwable exception)
//package com.java2s; //License from project: Apache License import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; public class Main { /**//www .j a va 2s . co m * A singleton instance of a Throwable indicating a terminal state for exceptions, * don't leak this! */ public static final Throwable TERMINATED = new Throwable("No further exceptions"); public static <T> boolean addThrowable(AtomicReferenceFieldUpdater<T, Throwable> field, T instance, Throwable exception) { for (;;) { Throwable current = field.get(instance); if (current == TERMINATED) { return false; } Throwable update; if (current == null) { update = exception; } else { update = new Throwable("Multiple exceptions"); update.addSuppressed(current); update.addSuppressed(exception); } if (field.compareAndSet(instance, current, update)) { return true; } } } }