public static void Main(string[] args) { // parse arguments int[] parameters = ParseArgs(args); if (parameters == null) { return; } PriorityTest priorityTest = new PriorityTest(1000000, 5000, parameters[0], 17, 30, 3); ThreadStart startDelegate = new ThreadStart(priorityTest.RunTest); // create threads Thread[] threads = new Thread[parameters[1]]; for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(startDelegate); threads[i].Name = String.Format("Thread{0}", i); threads[i].Start(); } // wait for threads to complete for (int i = 0; i < threads.Length; i++) { threads[i].Join(); } }
public SimpleHeap(int maxlength, PriorityTest prio) { _hleng = maxlength + 1; _hdata = new T[_hleng]; _hdata[0] = default(T); _prio = prio; _count = 0; }
static void Main() { PriorityTest priorityTest = new PriorityTest(); Thread thread1 = new Thread(priorityTest.ThreadMethod); Thread thread2 = new Thread(priorityTest.ThreadMethod); Thread thread3 = new Thread(priorityTest.ThreadMethod); thread1.Start(); thread2.Start(); thread3.Start(); Console.ReadLine(); priorityTest.LoopSwitch = false; Console.ReadLine(); priorityTest.Pulse(); Console.Read(); }
public static void Run() { PriorityTest priorityTest = new PriorityTest(); ThreadStart startDelegate = new ThreadStart(priorityTest.ThreadMethod); Thread threadOne = new Thread(startDelegate); threadOne.Name = "ThreadOne"; Thread threadTwo = new Thread(startDelegate); threadTwo.Name = "ThreadTwo"; threadTwo.Priority = ThreadPriority.Highest; threadOne.Start(); threadTwo.Start(); threadTwo.Priority = ThreadPriority.Highest; // Allow counting for 10 seconds. Thread.Sleep(1000); priorityTest.LoopSwitch = false; }
public static int Main(string[] args) { // parse arguments int[] parameters = ParseArgs(args); if (parameters == null) { return(0); } // set process affinity to 1 to repro bug easier //Process.GetCurrentProcess().ProcessorAffinity = (IntPtr)1; PriorityTest priorityTest = new PriorityTest(1000000, 5000, parameters[0], 17, 30, 3); ThreadStart startDelegate = new ThreadStart(priorityTest.RunTest); // create threads Thread[] threads = new Thread[parameters[1]]; for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(startDelegate); threads[i].IsBackground = true; threads[i].Name = String.Format("Thread{0}", i); //if (i % 2 == 0) //{ // threads[i].Priority = ThreadPriority.Lowest; //} threads[i].Start(); } // wait for threads to complete for (int i = 0; i < threads.Length; i++) { threads[i].Join(); } return(100); }
static void Main() { PriorityTest priorityTest = new PriorityTest(); Thread thread1 = new Thread(priorityTest.ThreadMethod); thread1.Name = "ThreadOne"; Thread thread2 = new Thread(priorityTest.ThreadMethod); thread2.Name = "ThreadTwo"; thread2.Priority = ThreadPriority.BelowNormal; Thread thread3 = new Thread(priorityTest.ThreadMethod); thread3.Name = "ThreadThree"; thread3.Priority = ThreadPriority.AboveNormal; thread1.Start(); thread2.Start(); thread3.Start(); // Allow counting for 10 seconds. Thread.Sleep(10000); priorityTest.LoopSwitch = false; }
static void Main() { PriorityTest priorityTest = new PriorityTest(); //create new переменную класса PriorityTest Thread thread1 = new Thread(priorityTest.ThreadMethod); //create new поток класса Thread thread1.Name = "Thread1"; Thread thread2 = new Thread(priorityTest.ThreadMethod);//create new поток класса Thread thread2.Name = "Thread2"; thread2.Priority = ThreadPriority.Lowest; //выдача приоритета Thread thread3 = new Thread(priorityTest.ThreadMethod); //create new поток класса Thread thread3.Name = "Thread3"; thread3.Priority = ThreadPriority.Highest;//выдача приоритета thread1.Start(); thread2.Start(); thread3.Start(); // Allow counting for 10 seconds. Thread.Sleep(100); //время работы потоков priorityTest.LoopSwitch = false; Console.ReadKey(); }
public static void Main(string[] args) { var priorityTest = new PriorityTest(); var startDelegate = new ThreadStart(priorityTest.ThreadMethod); var lowPriorityThread = new Thread(startDelegate); lowPriorityThread.Name = "Low priority thread"; lowPriorityThread.Priority = ThreadPriority.Lowest; for (int i = 1; i <= 2; i++) { var workerThread = new Thread(startDelegate); workerThread.Name = "High priority thread #" + i; workerThread.Priority = ThreadPriority.Highest; workerThread.Start(); } lowPriorityThread.Start(); Console.WriteLine(Process.GetCurrentProcess().Id); Console.WriteLine("Running.. press any key to exit"); Console.ReadKey(); priorityTest.IsRunning = false; }
public static int Main(string[] args) { // parse arguments int[] parameters = ParseArgs(args); if (parameters == null) { return 0; } // set process affinity to 1 to repro bug easier //Process.GetCurrentProcess().ProcessorAffinity = (IntPtr)1; PriorityTest priorityTest = new PriorityTest(1000000, 5000, parameters[0], 17, 30, 3); ThreadStart startDelegate = new ThreadStart(priorityTest.RunTest); // create threads Thread[] threads = new Thread[parameters[1]]; for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(startDelegate); threads[i].Name = String.Format("Thread{0}", i); //if (i % 2 == 0) //{ // threads[i].Priority = ThreadPriority.Lowest; //} threads[i].Start(); } // wait for threads to complete for (int i = 0; i < threads.Length; i++) { threads[i].Join(); } return 100; }
public SimpleHeap(PriorityTest prio) : this(default_length, prio) { }
public static void Main(string[] args) { // parse arguments int[] parameters = ParseArgs(args); if (parameters==null) { return; } PriorityTest priorityTest = new PriorityTest(1000000, 5000, parameters[0], 17, 30, 3); ThreadStart startDelegate = new ThreadStart(priorityTest.RunTest); // create threads Thread[] threads = new Thread[parameters[1]]; for (int i=0; i<threads.Length; i++) { threads[i] = new Thread(startDelegate); threads[i].Name = String.Format("Thread{0}", i); threads[i].Start(); } // wait for threads to complete for (int i=0; i<threads.Length; i++) { threads[i].Join(); } }