*   >> Lecture Éducation Articles >> science >> la programmation

Application console pour Threading utilisant System.Threading en C # 1.1 et 2.0 (Dot Net)

//application console pour Threading utilisant System.Threading en C # 1.1 et 2.0 (Dot Net)

using System;

utilisant System.Threading;

namespace Thred

{

classe Thred

{

static void Main ( )

{

cs mt = new cs ();

mt.t1 = new Thread (nouvelle ThreadStart (mt.method1));

mt.t2 = new Thread (nouvelle ThreadStart (mt.method2));

mt.t1.Start ();

mt.t2.Start ();

Console.

ReadLine ();

}

}

classe cs

{

t1 discussion publique, t2;

method1 public void ()

{

for (int j = 0; j

{

Console.WriteLine ("Thread1" + j);

Thread.Sleep (1000);

}

t2.Suspend ();

t2.Resume ();

}

public void method2 ()

{

t1.Suspend ();

t1.Resume ();

pour (int i = 0; i

​​{

Console.WriteLine ("Thread2" + i);

Thread.

Sleep (2000);

}

}

}

}


Copyright © 2008 - 2016 Lecture Éducation Articles,https://lecture.nmjjxx.com All rights reserved.