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 */
19 pthread_exit (IntPtr.Zero);
20 } catch (EntryPointNotFoundException) {
24 ExitThread (IntPtr.Zero);
25 } catch (EntryPointNotFoundException) {
30 static Thread GetThread2 ()
32 return new Thread (() => {
33 /* Exit without returning from the ThreadStart delegate */
34 Thread.CurrentThread.Abort ();
38 static Thread GetThread3 ()
40 return new Thread (() => {
41 /* Exit by returning from the ThreadStart delegate */
46 static Thread[] CreateThreads ()
48 return new Thread [] {
55 public static void Main ()
60 threads = CreateThreads ();
62 for (int i = 0; i < threads.Length; ++i)
65 for (int i = 0; i < threads.Length; ++i)
70 threads = CreateThreads ();
72 for (int i = 0; i < threads.Length; ++i)