Professional Documents
Culture Documents
Thread Priority
2. MyThreadClass Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace Thread_Priority
{
internal class MyThreadClass
{
public static void Thread1()
{
}
public static void Thread2()
{
for (int t2 = 0; t2 <= 6; t2++)
{
Thread thread = Thread.CurrentThread;
Console.WriteLine("Name of thread: " + thread.Name + " = " +
t2);
Thread.Sleep(1500);
}
}
}
}
3. FrmTrackThread Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Thread_Priority
{
public partial class frmTrackThread : Form
{
public frmTrackThread()
{
InitializeComponent();
}
ThreadA.Priority = ThreadPriority.Highest;
ThreadB.Priority = ThreadPriority.Normal;
ThreadC.Priority = ThreadPriority.AboveNormal;
ThreadD.Priority = ThreadPriority.BelowNormal;
ThreadA.Start();
ThreadB.Start();
ThreadC.Start();
ThreadD.Start();
ThreadA.Join();
ThreadB.Join();
ThreadC.Join();
ThreadD.Join();
Console.WriteLine("-End of Thread-");
Thread Start:
End of the Thread: