diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php
index 0167a74..1e1a613 100644
--- a/core/lib/Drupal/Core/Theme/Registry.php
+++ b/core/lib/Drupal/Core/Theme/Registry.php
@@ -216,7 +216,9 @@ public function get() {
       $this->registry = $cache->data;
     }
     else {
-      $this->registry = $this->build();
+      if ($this->lock->acquire('theme_registry_build')) {
+        $this->registry = $this->build();
+      }
       // Only persist it if all modules are loaded to ensure it is complete.
       if ($this->moduleHandler->isLoaded()) {
         $this->setCache();
@@ -361,6 +363,7 @@ protected function build() {
     }
     $this->registry = $cache;
 
+    $this->lock->release('theme_registry_build');
     return $this->registry;
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
index e0c20cd..57d2d9e 100644
--- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php
@@ -109,6 +109,14 @@ public function testGetRegistryForModule() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('getModuleList')
       ->willReturn([]);
+    $this->lock->expects($this->once())
+      ->method('acquire')
+      ->with('theme_registry_build')
+      ->willReturn(TRUE);
+    $this->lock->expects($this->once())
+      ->method('release')
+      ->with('theme_registry_build')
+      ->willReturn(FALSE);
 
     $registry = $this->registry->get();
 
