*   >> Lezen Onderwijs artikelen >> science >> programming

Console applicatie voor Threading gebruik System.Threading in C # 1.1 en 2.0 (Dot Net)

//console Aanvraag voor Threading gebruik System.Threading in C # 1.1 en 2.0 (Dot Net)

using System;

met System.Threading;

namespace thred

{

class thred

{

static void Main ( )

{

cs mt = new cs ();

mt.t1 = nieuwe thread (nieuw ThreadStart (mt.method1)),

mt.t2 = nieuwe thread (nieuw ThreadStart (mt.method2));

mt.t1.Start ();

mt.t2.Start ();

Console.ReadLine ();

}

}

class cs

{

openbare discussie T1, T2;

public void method1 ()

{

voor (int j = 0; j

{

Console.

WriteLine ("thread1" + j);

Thread.Sleep (1000);

}

t2.Suspend ();

t2.Resume ();

}

public void method2 ()

{

t1.Suspend ();

t1.Resume ();

voor (int i = 0; i

​​{

Console.WriteLine ("thread2" + i);

Thread.Sleep (2000);

}

}

}

}


Copyright © 2008 - 2016 Lezen Onderwijs artikelen,https://onderwijs.nmjjxx.com All rights reserved.