public void runEdtSafeAction(@NotNull Runnable runnable) { Integer value = ourEdtSafe.get(); if (value == null) { value = Integer.valueOf(0); } ourEdtSafe.set(value + 1); try { runnable.run(); } finally { int newValue = ourEdtSafe.get() - 1; ourEdtSafe.set(newValue >= 1 ? newValue : null); } }
public static boolean setExceptionalThreadWithReadAccessFlag(boolean flag) { boolean old = isExceptionalThreadWithReadAccess(); if (flag) { exceptionalThreadWithReadAccessFlag.set(Boolean.TRUE); } else { exceptionalThreadWithReadAccessFlag.remove(); } return old; }