3 using System
.Runtime
.InteropServices
;
4 using System
.Threading
;
9 extern static void pthread_exit (IntPtr
value);
11 [DllImport ("kernel32")]
12 extern static void ExitThread (IntPtr
value);
14 static Thread
GetThread1 ()
16 return new Thread (() => {
17 /* Exit bypassing completely the runtime */
18 if (Environment
.OSVersion
.Platform
== PlatformID
.Unix
|| Environment
.OSVersion
.Platform
== PlatformID
.MacOSX
)
19 pthread_exit (IntPtr
.Zero
);
21 ExitThread (IntPtr
.Zero
);
25 static Thread
GetThread2 ()
27 return new Thread (() => {
28 /* Exit without returning from the ThreadStart delegate */
29 Thread
.CurrentThread
.Abort ();
33 static Thread
GetThread3 ()
35 return new Thread (() => {
36 /* Exit by returning from the ThreadStart delegate */
41 static Thread
[] CreateThreads ()
43 return new Thread
[] {
50 public static void Main ()
55 threads
= CreateThreads ();
57 for (int i
= 0; i
< threads
.Length
; ++i
)
60 for (int i
= 0; i
< threads
.Length
; ++i
)
65 threads
= CreateThreads ();
67 for (int i
= 0; i
< threads
.Length
; ++i
)