[treadpool] Fix flaky System.Threading.ThreadTest.SetNameInThreadPoolThread test...
authorLudovic Henry <ludovic@xamarin.com>
Thu, 16 Feb 2017 12:20:41 +0000 (07:20 -0500)
committerGitHub <noreply@github.com>
Thu, 16 Feb 2017 12:20:41 +0000 (07:20 -0500)
mcs/class/corlib/Test/System.Threading/ThreadTest.cs

index ae5bdbfd586d3391d656861047590897068957ca..a84fa27a77d742a5faaebda98b46758d2bff70e6 100644 (file)
@@ -912,20 +912,18 @@ namespace MonoTests.System.Threading
                [Test]
                public void SetNameInThreadPoolThread ()
                {
-                       for (int i = 0; i < 10; ++i) {
-                               Task t = Task.Run (delegate () {
-                                       Thread.CurrentThread.Name = "x/" + i;
-                                       Assert.AreEqual (Thread.CurrentThread.Name, "x/" + i, "#1");
+                       Task t = Task.Run (delegate () {
+                               Thread.CurrentThread.Name = "ThreadName1";
+                               Assert.AreEqual (Thread.CurrentThread.Name, "ThreadName1", "#1");
 
-                                       try {
-                                               Thread.CurrentThread.Name = "y/" + i;
-                                               Assert.Fail ("#2");
-                                       } catch (InvalidOperationException) {
-                                       }
-                               });
+                               try {
+                                       Thread.CurrentThread.Name = "ThreadName2";
+                                       Assert.Fail ("#2");
+                               } catch (InvalidOperationException) {
+                               }
+                       });
 
-                               t.Wait ();
-                       }
+                       t.Wait ();
                }
 
                void CheckIsRunning (string s, Thread t)