Priorities

Up to now, all threads had the same priority and therefore all threads were called exactly three times. One thread was called after the other. However, sometimes some threads are more important than others because they have to run faster.

In the next example, you can see how different priorities can be assigned to a thread (Thread.Priority has not been fully implemented yet):

 using System; using System.Threading; public class MyThread { public static void Thr() { for (int i = 0; i < 3; i++) { Thread tr = Thread.CurrentThread; Console.WriteLine("{0} Thread: {1}", i, tr.Name ); Thread.Sleep(1); } } } public class Demo { public static void Main() { Thread th1 = new Thread(new ThreadStart(MyThread.Thr)); th1.Name = "Thread 1"; th1.Priority ...

Get Mono Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.