diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php
index e23af78..d8c0cfe 100644
--- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php
+++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php
@@ -20,11 +20,6 @@
 class CommentStorageController extends FieldableDatabaseStorageController implements CommentStorageControllerInterface {
 
   /**
-   * The thread for which a lock was acquired.
-   */
-  protected $threadLock = '';
-
-  /**
    * {@inheritdoc}
    */
   protected function buildQuery($ids, $revision_id = FALSE) {
diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php
index d2c79bd..ddedfb0 100644
--- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php
+++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php
@@ -57,6 +57,11 @@
 class Comment extends ContentEntityBase implements CommentInterface {
 
   /**
+   * The thread for which a lock was acquired.
+   */
+  protected $threadLock = '';
+
+  /**
    * The comment ID.
    *
    * @var \Drupal\Core\Field\FieldItemListInterface
@@ -273,12 +278,13 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
           }
         }
         // Finally, build the thread field for this new comment. To avoid
-        // race conditions, get a lock on the thread. If aother process already
+        // race conditions, get a lock on the thread. If another process already
         // has the lock, just move to the next integer.
         do {
           $thread = $prefix . comment_int_to_alphadecimal(++$n) . '/';
-        } while (!lock()->acquire("comment:{$this->entity_id->value}:$thread"));
-        $this->threadLock = $thread;
+          $lock_name = "comment:{$this->entity_id->value}:$thread";
+        } while (!\Drupal::lock()->acquire($lock_name));
+        $this->threadLock = $lock_name;
       }
       if (empty($this->created->value)) {
         $this->created->value = REQUEST_TIME;
@@ -316,7 +322,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
    */
   protected function releaseThreadLock() {
     if ($this->threadLock) {
-      lock()->release($this->threadLock);
+      \Drupal::lock()->release($this->threadLock);
       $this->threadLock = '';
     }
   }
