You are on page 1of 1

sing 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 LabExam
{
public partial class frmTrackThread : Form
{
public frmTrackThread()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
Console.WriteLine("-Thread Start-");
lblThread.Text = "-Thread Start-";

ThreadStart thread1 = new ThreadStart(MyThreadClass.Thread1);


ThreadStart thread2 = new ThreadStart(MyThreadClass.Thread2);

Thread threadA = new Thread(thread1);


Thread threadB = new Thread(thread1);
Thread threadC = new Thread(thread2);
Thread threadD = new Thread(thread2);

threadA.Name = "Thread A Process ";


threadB.Name = "Thread B Process ";
threadC.Name = "Thread C Process ";
threadD.Name = "Thread D Process ";

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-");
lblThread.Text = "-End of Thread-";
}
}
}

You might also like