diff --git a/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp b/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp
index 770a9d8f054..6f10f8cbd72 100644
--- a/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp
+++ b/test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp
@@ -40,6 +40,10 @@
 
 #include <stdio.h>
 
+#include <pthread.h>
+static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
+//static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; // Linux
+
 // #define LOG(...) printf(__VA_ARGS__); printf("\n"); fflush(stdout);
 #define LOG(...)
 
@@ -74,24 +78,25 @@ static void check_inner(const ReservedMemoryRegion& rmr, R* regions, size_t regi
 
 #define WHERE " from " << file << ":" << line
 
+  pthread_mutex_lock(&lock);
   VirtualMemoryTracker::Instance::tree()->visit_committed_regions(rmr, [&](CommittedMemoryRegion& region) {
     EXPECT_LT(i, regions_size) << WHERE;
     EXPECT_EQ(region.base(), regions[i]._addr) << WHERE;
     EXPECT_EQ(region.size(), regions[i]._size) << WHERE;
     size += region.size();
     i++;
+    pthread_mutex_unlock(&lock);
     return true;
   });
 
   EXPECT_EQ(i, regions_size) << WHERE;
   EXPECT_EQ(size, rmr.committed_size()) << WHERE;
+  pthread_mutex_unlock(&lock);
 }
 
 class VirtualMemoryTrackerTest {
 public:
   static void test_add_committed_region_adjacent() {
-    MemTracker::NmtVirtualMemoryLocker nvml;
-
     size_t size  = 0x01000000;
     ReservedSpace rs = MemoryReserver::reserve(size, mtTest);
 
@@ -104,8 +109,9 @@ class VirtualMemoryTrackerTest {
     NativeCallStack stack2(&frame2, 1);
 
     // Fetch the added RMR for the space
-    ReservedMemoryRegion rmr = VirtualMemoryTracker::Instance::tree()->find_reserved_region(addr);
+    pthread_mutex_lock(&lock);
     RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
+    ReservedMemoryRegion rmr = rtree->find_reserved_region(addr);
 
     ASSERT_EQ(rmr.size(), size);
     ASSERT_EQ(rmr.base(), addr);
@@ -164,17 +170,16 @@ class VirtualMemoryTrackerTest {
     // Cleanup
     rtree->uncommit_region(addr, 3 * cs);
     ASSERT_EQ(rmr.committed_size(), 0u);
+    pthread_mutex_unlock(&lock);
   }
 
   static void test_add_committed_region_adjacent_overlapping() {
-    MemTracker::NmtVirtualMemoryLocker nvml;
-
-    RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
-    rtree->tree().remove_all();
-
     size_t size  = 0x01000000;
     ReservedSpace rs = MemoryReserver::reserve(size, mtTest);
 
+    pthread_mutex_lock(&lock);
+    RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
+
     address addr = (address)rs.base();
 
     address frame1 = (address)0x1234;
@@ -253,17 +258,18 @@ class VirtualMemoryTrackerTest {
                 {addr + 3 * cs, 2 * cs} };
       check(rmr, r);
     }
-  }
-
-  static void test_add_committed_region_overlapping() {
-    MemTracker::NmtVirtualMemoryLocker nvml;
 
-    RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
     rtree->tree().remove_all();
+    pthread_mutex_unlock(&lock);
+  }
 
+  static void test_add_committed_region_overlapping() {
     size_t size  = 0x01000000;
     ReservedSpace rs = MemoryReserver::reserve(size, mtTest);
 
+    pthread_mutex_lock(&lock);
+    RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
+
     address addr = (address)rs.base();
 
     address frame1 = (address)0x1234;
@@ -419,12 +425,19 @@ class VirtualMemoryTrackerTest {
                 {addr + 2 * cs, cs} };
       check(rmr, r);
     }
+
+    rtree->tree().remove_all();
+    pthread_mutex_unlock(&lock);
   }
 
   static void test_add_committed_region() {
+    //pthread_mutex_lock(&lock);
+
     test_add_committed_region_adjacent();
     test_add_committed_region_adjacent_overlapping();
     test_add_committed_region_overlapping();
+
+    //pthread_mutex_unlock(&lock);
   }
 
   template <size_t S>
@@ -433,14 +446,12 @@ class VirtualMemoryTrackerTest {
   }
 
   static void test_remove_uncommitted_region() {
-    MemTracker::NmtVirtualMemoryLocker nvml;
-
-    RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
-    rtree->tree().remove_all();
-
     size_t size  = 0x01000000;
     ReservedSpace rs = MemoryReserver::reserve(size, mtTest);
 
+    pthread_mutex_lock(&lock);
+    RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
+
     address addr = (address)rs.base();
 
     address frame1 = (address)0x1234;
@@ -560,6 +571,9 @@ class VirtualMemoryTrackerTest {
       rtree->uncommit_region(addr, 3 * cs);
       check_empty(rmr);
     }
+
+    rtree->tree().remove_all();
+    pthread_mutex_unlock(&lock);
   }
 };
 
