//Aplicación de consola para roscar usando System.Threading en C # 1.1 y 2.0 (Dot Net)
using System;
usando System.Threading;
espacio de nombres thred
{
clase thred
{
static void Main ( )
{
cs tm = new cs ();
mt.t1 = new Thread (nueva ThreadStart (mt.method1));
mt.t2 = new Thread (nueva ThreadStart (mt.method2));
mt.t1.Start ();
mt.t2.Start ();
Console.
ReadLine ();
}
}
clase cs
{
t1 Tema pública, t2;
pública metodo1 void ()
{
for (int j = 0; j
{
Console.WriteLine ("Thread1" + j);
Thread.Sleep (1000);
}
t2.Suspend ();
t2.Resume ();
}
public void metodo2 ()
{
t1.Suspend ();
t1.Resume ();
para (int i = 0; i
{
Console.WriteLine ("Thread2" + i);
Thread.
Sleep (2000);
}
}
}
}