IT1811
Task
Performance
Thread Priority
Objectives:
At the end of the exercise, the students should be able to:
Distinguish a thread from a process; and
Describe the process of multithreading.
Software Requirement:
One (1) personal computer with pre-installed Windows Operating System
Visual Studio IDE 2015 or higher
Procedures:
Instructions:
1. Create a program that displays the processes of different threads. The program should only have one (1)
Windows form named frmTrackThread.
2. Create a class named MyThreadClass. Then, declare two (2) static methods named Thread1 and
Thread2.
04 Task Performance 1 *Property of STI
Page 1 of 5
IT1811
3. Create a loop that loops two (2) times in Thread1. Suspend the current thread for 0.5 seconds. Add the
following code inside the loop.
Thread thread = Thread.CurrentThread;
Console.WriteLine("Name of Thread: " + thread.Name + " = " + loopCount);
4. In Thread2, create a loop that loops six (6) times and suspends the current thread for 1.5 seconds. Same as in
Step 3, add the following code inside the loop.
04 Task Performance 1 *Property of STI
Page 2 of 5
IT1811
5. In the frmTrackThread class, create four (4) threads named threadA, threadB, threadC, and
threadD. The program’s output should be displayed in a console to track the process of each thread.
6. Set the priority for each thread. See table below.
Name of Thread ThreadPriority
threadA Highest
threadB Normal
threadC AboveNormal
threadD BelowNormal
7. Use the Join() method to stop a calling thread until the thread terminates.
04 Task Performance 1 *Property of STI
Page 3 of 5
IT1811
Code:
04 Task Performance 1 *Property of STI
Page 4 of 5
IT1811
04 Task Performance 1 *Property of STI
Page 5 of 5