diff --git a/src/tests/GC/API/GC/GetTotalAllocatedBytes.cs b/src/tests/GC/API/GC/GetTotalAllocatedBytes.cs index d0f6c158cf4548..d7468344de77b3 100644 --- a/src/tests/GC/API/GC/GetTotalAllocatedBytes.cs +++ b/src/tests/GC/API/GC/GetTotalAllocatedBytes.cs @@ -110,7 +110,7 @@ public static void TestAnotherThread() object lck = new object(); tsk = Task.Run(() => { - while (running) + for (int i = 0; i < 1000; i++) { Thread thd = new Thread(() => { lock (lck) @@ -121,11 +121,14 @@ public static void TestAnotherThread() thd.Start(); thd.Join(); + + if (!running) + break; } }); Counts previous = default(Counts); - for (int i = 0; i < 1000; ++i) + for (int i = 0; i < 100; ++i) { lock (lck) {