[Mono-list] Multithreaded output : bug or feature
Yury Serdyuk
Yury at serdyuk.botik.ru
Thu Apr 24 08:32:27 EDT 2008
Hi !
I have tried the following program:
using System;
using System.Threading;
public class MultiThreadedOutput {
public static void Main ( String[] args ) {
int P = Convert.ToInt32 ( args [ 0 ] );
for ( int i = 0; i < P; i++ ) {
ThreadObject tobj = new ThreadObject ( i );
Thread t = new Thread ( new ThreadStart ( tobj.Run ) );
t.Start ();
}
Console.ReadKey ();
}
}
public class ThreadObject {
private int myNumber;
public ThreadObject ( int i ) {
myNumber = i;
}
public void Run () {
Console.WriteLine ( "Thread " + myNumber + " start ..." );
Console.WriteLine ( "Thread " + myNumber + " finish ..." );
}
}
The output which I got:
> [serdyuk at node-284 nqueen]$ mono MultiThreadedOutput.exe 1
> Thread 0 start ...
> Thread 0 finish ...
>
> [serdyuk at node-284 nqueen]$ mono MultiThreadedOutput.exe 2
> Thread 1 start ...Thread 0 start ...Thread 1 start ...Thread 0 start ...
>
> Thread 0 finish ...
> Thread 1 finish ...
>
> [serdyuk at node-284 nqueen]$ mono MultiThreadedOutput.exe 3
> Thread 0 start ...Thread 1 start ...Thread 2 start ...Thread 0 start
> ...Thread 0 start ...Thread 1 start ...Thread 2 start ...
> Thread 0 finish ...
>
> Thread 1 finish ...
>
> Thread 2 finish ...
Is it true ?
Under Windows I got like:
> D:\users\serdyuk>MultiThreadedOutput 1
> Thread 0 start ...
> Thread 0 finish ...
>
> D:\users\serdyuk>MultiThreadedOutput 2
> Thread 0 start ...
> Thread 0 finish ...
> Thread 1 start ...
> Thread 1 finish ...
>
> D:\users\serdyuk>MultiThreadedOutput 2
> Thread 0 start ...
> Thread 1 start ...
> Thread 0 finish ...
> Thread 1 finish ...
>
> D:\users\serdyuk>MultiThreadedOutput 2
> Thread 1 start ...
> Thread 0 start ...
> Thread 0 finish ...
> Thread 1 finish ...
I have tried my program under
> [serdyuk at node-284 nqueen]$ mono -V
> Mono JIT compiler version 1.9.1 (tarball)
> Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
> TLS: __thread
> GC: Included Boehm (with typed GC)
> SIGSEGV: altstack
> Notifications: epoll
> Architecture: amd64
> Disabled: none
> [serdyuk at node-284 nqueen]$ uname -a
> Linux node-284 2.6.21-1.3194.fc8 #1 SMP Tue Feb 12 18:15:41 EET 2008
> x86_64 x86_64 x86_64 GNU/Linux
> [serdyuk at node-284 proc]$ cat cpuinfo
> processor : 0
> vendor_id : AuthenticAMD
> cpu family : 15
> model : 33
> model name : Dual Core AMD Opteron(tm) Processor 875 HE
( 2 processors ).
Thanks.
Yury Serdyuk
More information about the Mono-list
mailing list