optaplanner-core/src/main/java/org/optaplanner/core/impl/solver/scope/DefaultSolverScope.java
public void checkYielding() {
        if (runnableThreadSemaphore != null) {
            runnableThreadSemaphore.release();
            try {
                runnableThreadSemaphore.acquire();
            } catch (InterruptedException e) {
                // The BasicPlumbingTermination will terminate the solver.
                Thread.currentThread().interrupt();
            }
        }
    }
public void checkYielding() {
        if (runnableThreadSemaphore != null) {
            runnableThreadSemaphore.release();
            try {
                runnableThreadSemaphore.acquire();
            } catch (InterruptedException e) {
                // The BasicPlumbingTermination will terminate the solver.
                Thread.currentThread().interrupt();
            }
        }
    }
Similar to {@link Thread#yield()}, but allows capping the number of active solver threads
at less than the CPU processor count, so other threads (for example servlet threads that handle REST calls)
and other processes (such as SSH) have access to uncontested CPUs and don't suffer any latency.
<p>
Needs to be called <b>before</b> {@link Termination#isPhaseTerminated(AbstractPhaseScope)},
so the decision to start a new iteration is after any yield waiting time has been consumed
(so {@link Solver#terminateEarly()} reacts immediately).