|
using System;
using System.Threading;
public class MyThread {
public void Thread1() {
for (int i = 0; i < 10; i++) {
int iHour = 0;
int iMin = 0;
int iSec = -1;
try {
Console.WriteLine("Hello world " + i);
Thread.Sleep(new TimeSpan(iHour, iMin, iSec) );
}
catch (ArgumentException ae) {
Console.WriteLine(ae.Message );
}
}
}
}
public class MyClass {
public static void Main() {
Console.WriteLine("Before start thread");
MyThread thr1 = new MyThread();
MyThread thr2 = new MyThread();
Thread tid1 = new Thread(new ThreadStart(thr1.Thread1) );
Thread tid2 = new Thread(new ThreadStart(thr2.Thread1) );
tid1.Start();
tid2.Start();
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.