*   >> Lese Utdanning Artikler >> science >> programming

Console Application for Threading bruker System.Threading i C # 1.1 og 2.0 (Dot Net)

//konsollen Søknad om Threading bruker System.Threading i C # 1.1 og 2.0 (Dot Net)

bruker System;

bruker System.Threading;

navnerom thred

{

klasse thred

{

static void main ( )

{

cs mt = new cs ();

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

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

mt.t1.Start ();

mt.t2.Start ();

Console.

ReadLine ();

}

}

klasse cs

{

offentlig Thread t1, t2;

public void Method1 ()

{

for (int j = 0; j

{

Console.WriteLine ("Thread1" + j);

Thread.Sleep (1000);

}

t2.Suspend ();

t2.Resume ();

}

public void method2 ()

{

t1.Suspend ();

t1.Resume ();

for (int i = 0; i

​​{

Console.WriteLine ("gjenger2" + i);

Thread.

Sleep (2000);

}

}

}

} Anmeldelser

Copyright © 2008 - 2016 Lese Utdanning Artikler,https://utdanning.nmjjxx.com All rights reserved.