diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index 3897d70490d..b715f7783d5 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -440,6 +440,11 @@ CompileTask* CompileQueue::get(CompilerThread* thread) { AbstractCompiler* compiler = thread->compiler(); guarantee(compiler != nullptr, "Compiler object must exist"); compiler->on_empty_queue(this, thread); + if (_first != nullptr) { + // The call to on_empty_queue may have temporarily unlocked the MCQ lock + // so check again whether any tasks were added to the queue. + break; + } // If there are no compilation tasks and we can compile new jobs // (i.e., there is enough free space in the code cache) there is