Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mono/tests/threadpool.cs')
-rwxr-xr-xmono/tests/threadpool.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/mono/tests/threadpool.cs b/mono/tests/threadpool.cs
new file mode 100755
index 00000000000..cfcc6ee4c8a
--- /dev/null
+++ b/mono/tests/threadpool.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Threading;
+
+public class Test {
+
+ static int csum = 0;
+
+ public static void test_callback (object state) {
+ Console.WriteLine("test_casllback:" + state);
+ Thread.Sleep (200);
+ Interlocked.Increment (ref csum);
+ }
+
+ public static int Main () {
+ int workerThreads;
+ int completionPortThreads;
+
+ ThreadPool.GetMaxThreads (out workerThreads, out completionPortThreads);
+ Console.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads, completionPortThreads);
+
+ ThreadPool.GetAvailableThreads (out workerThreads, out completionPortThreads);
+ Console.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads, completionPortThreads);
+
+ ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST1");
+ ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST2");
+ ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST3");
+ ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST4");
+ ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback), "TEST5");
+ ThreadPool.QueueUserWorkItem (new WaitCallback (test_callback));
+
+ while (csum < 6) {
+ Thread.Sleep (100);
+ }
+
+ Console.WriteLine ("CSUM: " + csum);
+
+ if (csum != 6)
+ return 1;
+
+ return 0;
+ }
+}
+