[Mono-devel-list] Threading bug?

Simon Ask Ulsnes simon at ulsnes.dk
Mon Mar 10 16:06:18 EST 2003


The attached program generates the attached output on my machine.
As you can probably guess from the source, the output was supposed to look like this:

<OUTPUT>
<ctrl+c to stop>
Queueing new thread...
<subthread 1> Sleeping 10 seconds...
Queueing new thread...
<subthread 2> Sleeping 10 seconds...
Queueing new thread...
<subthread 3> Sleeping 10 seconds...
and so on...
</OUTPUT>

...but it doesn't! As you can see in my output-file, the first thread is started and runs fine, then all the other threads are queued, but they don't actually run.

If it behaves the same way on your machines, I would characterize this as a bug in the Mono threading library...

Yours sincerely,
Simon Ask Ulsnes
-------------- next part --------------
using System;
using System.Threading;

public class ThreadingTest
{
	public ThreadingTest()
	{
		Console.WriteLine("<ctrl+c to stop>");
		int numthreads = 0;
		while (true)
		{
			Console.WriteLine("Queueing new thread...");
			numthreads++;
			ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadProcedure), numthreads);
			Thread.Sleep(1000);
		}
	}

	public void ThreadProcedure(object state)
	{
		Console.WriteLine("<subthread "+((int)state).ToString()+"> Sleeping 10 seconds...");
		Thread.Sleep(10000);
		Console.WriteLine("<subthread "+((int)state).ToString()+"> Finished.");
	}

	public static void Main(string[] args)
	{
		ThreadingTest tt = new ThreadingTest();
	}
}
-------------- next part --------------
<ctrl+c to stop>
Queueing new thread...
<subthread 1> Sleeping 10 seconds...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
<subthread 1> Finished.
<subthread 2> Sleeping 10 seconds...
<subthread 3> Sleeping 10 seconds...
<subthread 4> Sleeping 10 seconds...
<subthread 5> Sleeping 10 seconds...
<subthread 6> Sleeping 10 seconds...
<subthread 7> Sleeping 10 seconds...
<subthread 8> Sleeping 10 seconds...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...
<subthread 2> Finished.
<subthread 3> Finished.
<subthread 4> Finished.
<subthread 5> Finished.
<subthread 6> Finished.
<subthread 8> Finished.
<subthread 7> Finished.
<subthread 9> Sleeping 10 seconds...
<subthread 10> Sleeping 10 seconds...
<subthread 11> Sleeping 10 seconds...
<subthread 12> Sleeping 10 seconds...
<subthread 13> Sleeping 10 seconds...
<subthread 14> Sleeping 10 seconds...
<subthread 15> Sleeping 10 seconds...
<subthread 16> Sleeping 10 seconds...
<subthread 17> Sleeping 10 seconds...
<subthread 18> Sleeping 10 seconds...
<subthread 19> Sleeping 10 seconds...
<subthread 20> Sleeping 10 seconds...
Queueing new thread...
<subthread 21> Sleeping 10 seconds...
Queueing new thread...
<subthread 22> Sleeping 10 seconds...
Queueing new thread...
<subthread 23> Sleeping 10 seconds...
Queueing new thread...
<subthread 24> Sleeping 10 seconds...
Queueing new thread...
Queueing new thread...
Queueing new thread...
Queueing new thread...


More information about the Mono-devel-list mailing list