C # Multithread operation example,
Using System; using System. threading; // reference multithreading namespace ThreadTest {public class Alpha {public void Beta () {while (true) {Console. writeLine ("Alpha. beta is running in its own thread. ") ;}}; public class Simple {public static int Main () {Console. writeLine ("Thread Start/Stop/Join Sample"); Alpha oAlpha = new Alpha (); // file: // create a Thread to execute Beta () of the Alpha Class () method Thread oThread = new Thread (new ThreadSta Rt (oAlpha. Beta); oThread. Start (); while (! OThread. isAlive) Thread. sleep (1); oThread. abort (); oThread. join (); Console. writeLine (); Console. writeLine ("Alpha. beta has finished "); try {Console. writeLine ("Try to restart the Alpha. beta thread "); oThread. start ();} catch (ThreadStateException) {Console. write ("ThreadStateException trying to restart Alpha. beta. "); Console. writeLine ("Expected since aborted threads cannot be restarted. "); Console. readLine () ;}return 0 ;}}}