Advertisement
Drainedsoul

SO C# Threading Multi Param

Jan 4th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4.  
  5. public static class ThreadTest {
  6.  
  7.  
  8.     public static void Main () {
  9.    
  10.         Thread t=new Thread(WriteString);
  11.         t.Start(new Object [] {(String)"y", (Int32)10});
  12.         Thread u=new Thread(WriteString);
  13.         u.Start(new Object [] {(String)"x", (Int32)25});
  14.        
  15.         t.Join();
  16.         u.Join();
  17.    
  18.     }
  19.    
  20.    
  21.     private static void WriteString (Object o) {
  22.    
  23.         Object [] param=(Object [])o;
  24.         String message=(String)param[0];
  25.         Int32 count=(Int32)param[1];
  26.        
  27.         for (Int32 i=0;i<count;++i) Console.WriteLine(message);
  28.    
  29.     }
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement