[Mono-bugs] [Bug 77773][Nor] New - Background threads keep process alive

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Mar 13 01:41:17 EST 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by paul.thomas at anu.edu.au.

http://bugzilla.ximian.com/show_bug.cgi?id=77773

--- shadow/77773	2006-03-13 01:41:17.000000000 -0500
+++ shadow/77773.tmp.1469	2006-03-13 01:41:17.000000000 -0500
@@ -0,0 +1,107 @@
+Bug#: 77773
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: Linux <<host>> 2.6.8-2-686-smp #1 SMP Thu May 19 17:27:55 JST 2005 i686 GNU/Linux
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: paul.thomas at anu.edu.au               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Background threads keep process alive
+
+Description of Problem:  
+  
+A thread with IsBackground = true keeps running and keeps the application 
+from terminating even when foreground threads have all stopped.  
+  
+Steps to reproduce the problem:  
+  
+using System;  
+using System.Threading;  
+  
+class ThreadBug {  
+  
+    static void Main() {  
+      Thread bg = new Thread(delegate { Loop(20); });  
+      bg.Name = "Background";  
+      bg.IsBackground = true;  
+  
+      Thread fg = new Thread(delegate { Loop(10); });  
+      fg.Name = "Foreground";  
+        
+      bg.Start();  
+      fg.Start();  
+    }  
+  
+  static void Loop(int reps) {  
+    string name = Thread.CurrentThread.Name;  
+    for (int i = 0; i < reps; i++) {  
+      Console.WriteLine("{0} iteration {1}", name, i);  
+      Thread.Sleep(100);  
+    }  
+  }  
+  
+}  
+  
+With either gmcs or mcs 1.1.13.2, run with mono 1.1.13.2 (no other  
+commandline args).  
+  
+Actual Results:  
+  
+Background iteration 0  
+Foreground iteration 0  
+Background iteration 1  
+Foreground iteration 1  
+[...]  
+Background iteration 9  
+Foreground iteration 9  
+Background iteration 10  
+Background iteration 11  
+Background iteration 12  
+Background iteration 13  
+Background iteration 14  
+Background iteration 15  
+Background iteration 16  
+Background iteration 17  
+Background iteration 18  
+Background iteration 19  
+  
+Expected Results:  
+  
+Background iteration 0  
+Foreground iteration 0  
+Background iteration 1  
+Foreground iteration 1  
+Foreground iteration 2  
+Background iteration 2  
+Foreground iteration 3  
+Background iteration 3  
+Foreground iteration 4  
+Background iteration 4  
+Background iteration 5  
+Foreground iteration 5  
+Foreground iteration 6  
+Background iteration 6  
+Foreground iteration 7  
+Background iteration 7  
+Foreground iteration 8  
+Background iteration 8  
+Background iteration 9  
+Foreground iteration 9  
+[and possibly a small number of extra background iterations]  
+  
+How often does this happen?   
+  
+Consistently.  
+  
+Additional Information:  
+  
+I get the same behaviour with threads started via ThreadStart, and other  
+delegates of various complexity.


More information about the mono-bugs mailing list