Dynamically create multiple threads

 

 static  void the Main ( String [] args) 
        { 
            int n-= 20 is ; // Open 20 threads 
            the Thread [] downloadThread; 
            ParameterizedThreadStart the startDownload = new new ParameterizedThreadStart (DownLoad); 
            downloadThread = new new [n-] the Thread; // thread application resources, determining the total number of threads 
            for ( int I = 0 ; I <n-; I ++) // open a specified number of threads 
            { 
                downloadThread [I] = new new the thread (the startDownload); //Specified thread initial setting 
                downloadThread [I] .Start (I); // by-turn thread 
            } 
}
 public static void DownLoad(object msg)
        {
            Console.WriteLine(msg.ToString());
        }

 

Guess you like

Origin www.cnblogs.com/macT/p/11793463.html