@Override public void run() { /* This resolves a know deadlock that can occur if one thread is in the process of defining a package as part of defining a class, and another thread is defining the system package that can result in loading a class. One holds the Package.pkgs lock and one holds the Classloader lock. */ Package.getPackages(); final Queue<LoadRequest> queue = LoaderThreadHolder.REQUEST_QUEUE; for (; ; ) { try { LoadRequest request; synchronized (queue) { while ((request = queue.poll()) == null) { queue.wait(); } } final ModuleClassLoader loader = request.requester; Class<?> result = null; synchronized (loader) { try { result = loader.performLoadClass(request.className, request.exportsOnly); } finally { // no matter what, the requester MUST be notified request.result = result; request.done = true; loader.notifyAll(); } } } catch (Throwable t) { // ignore } } }