boolean () { long time = System.nanoTime() - myPrioritizingStartedNanos; if (time < MIN_PRIORITIZATION_NANOS) { return false; // don't sleep when activities are very short (e.g., empty processing of mouseMoved events) } if (avoidBlockingPrioritizingThread()) { return false; } if (EDT.isCurrentThreadEdt()) { // EDT always has high priority return false; } if (time > MAX_PRIORITIZATION_NANOS) { // Don't wait forever in case someone forgot to stop prioritizing before waiting for other threads to complete // wait just for 12 seconds; this will be noticeable (and we'll get 2 thread dumps) but not fatal stopAllPrioritization(); return false; } return true; }