Update Haiku support (#15674)
[mono-project.git] / mono / tests / threadpool.cs
blob75791e37f4c8b1f87fc9a10338779a983334142d
1 using System;
2 using System.Threading;
4 public class ThreadPoolTest
7 static int csum = 0;
9 public static void test_callback (object state) {
10 Console.WriteLine("test_callback:" + state);
11 Thread.Sleep (200);
12 Interlocked.Increment (ref csum);
15 public static int Main () {
16 int workerThreads;
17 int completionPortThreads;
19 ThreadPool.GetMaxThreads (out workerThreads, out completionPortThreads);
20 Console.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads, completionPortThreads);
22 ThreadPool.GetAvailableThreads (out workerThreads, out completionPortThreads);
23 Console.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads, completionPortThreads);
25 ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST1");
26 ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST2");
27 ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST3");
28 ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST4");
29 ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST5");
30 ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback));
32 while (csum < 6) {
33 Thread.Sleep (100);
36 Console.WriteLine ("CSUM: " + csum);
38 if (csum != 6)
39 return 1;
41 return 0;