//sbool ping_actions_shareable = true; static volatile bool ping_pauseAll; static int ping_sleep = 100; // poll pauseAll flag every 100 ifndef LeanMode static volatile bool ping_anyActions; static Map ping_actions = newWeakHashMap(); static new ThreadLocal ping_isCleanUpThread; endifndef // always returns true static bool ping() { if (ping_pauseAll ifndef LeanMode || ping_anyActions endifndef) ping_impl(false); //ifndef LeanMode ping_impl(); endifndef true; } // returns true when it slept static bool ping_impl(bool okInCleanUp) ctex { if (ping_pauseAll && !isAWTThread()) { do Thread.sleep(ping_sleep); while (ping_pauseAll); true; } ifndef LeanMode if (ping_anyActions) { // don't allow sharing ping_actions if (!okInCleanUp && !isTrue(ping_isCleanUpThread!)) failIfUnlicensed(); O action = null; synchronized(ping_actions) { if (!ping_actions.isEmpty()) { action = ping_actions.get(currentThread()); if (action instanceof Runnable) ping_actions.remove(currentThread()); if (ping_actions.isEmpty()) ping_anyActions = false; } } if (action instanceof Runnable) ((Runnable) action).run(); else if (eq(action, "cancelled")) fail("Thread cancelled."); } endifndef ret false; }