private static boolean waitForSwing(Set<AbstractSwingUpdateManager> managers, boolean flush) {

		// Note: not sure how long is too long to wait for the Swing thread and update managers
		//       to finish.  This is usually less than a second.  We have seen a degenerate
		//       case where this took minutes.  This method is called often, so don't wait too
		//       long.  This will have to be changed through trial-and-error.
		int MAX_SWING_TIMEOUT = 15000;
		int totalTime = 0;

		// flush all managers up front to get them started before we check them
		flushAllManagers(managers, flush);

		boolean wasEverBusy = false;
		boolean keepGoing = true;
		while (keepGoing) {

			// let swing paint and maybe schedule more work on the update managers
			yieldToSwing();
			keepGoing = false;

			for (AbstractSwingUpdateManager manager : managers) {

				if (!manager.isBusy()) {
					// no current or pending work
					continue;
				}

				// Msg.out("busy manager: " + manager.toStringDebug());

				doFlush(flush, manager);

				boolean isBusy = true;
				while (isBusy) {

					keepGoing = true; // true, since we had a busy signal
					wasEverBusy = true;

					totalTime += sleep(DEFAULT_WAIT_DELAY);
					if (totalTime >= MAX_SWING_TIMEOUT) {
						// eject!
						Msg.debug(AbstractGenericTest.class,
							"Timed-out waitinig for Swing after " + totalTime + " ms.  " +
								"The currently waited SwingUpdateManager:\n" +
								manager.toStringDebug());
						return true;
					}

					isBusy = manager.isBusy();
				}
			}
			// let any resulting swing events finish
			yieldToSwing();
		}

		return wasEverBusy;
	}
Waits for the Swing thread to process any pending events. This method
also waits for any {@link SwingUpdateManager}s that have pending events
to be flushed.

@return true if the any {@link SwingUpdateManager}s were busy.
Ghidra/Framework/Gui/src/main/java/generic/test/AbstractGuiTest.java