2007-03-28 Chris Toshok <toshok@ximian.com>
[mono-project.git] / mono / tests / thread-stress.cs
blob1b6c7f941b5b45c665be551ca0176c1963927d91
1 using System;
2 using System.Threading;
4 class T {
5 static int loops = 20;
6 static int threads = 100;
8 static void worker () {
9 /* a writeline happens to involve lots of code */
10 Console.WriteLine ("Thread start " + Thread.CurrentThread.GetHashCode ());
13 static void doit () {
14 Thread[] ta = new Thread [threads];
15 for (int i = 0; i < threads; ++i) {
16 ta [i] = new Thread (new ThreadStart (worker));
17 ta [i].Start ();
19 for (int i = 0; i < threads; ++i) {
20 ta [i].Join ();
23 static void Main (string[] args) {
24 if (args.Length > 0)
25 loops = int.Parse (args [0]);
26 if (args.Length > 1)
27 threads = int.Parse (args [1]);
28 for (int i = 0; i < loops; ++i) {
29 doit ();