0% found this document useful (0 votes)
155 views5 pages

04 Task Performance 1

The document provides instructions for an exercise to help students distinguish threads from processes and describe multithreading. It instructs students to create a Windows form program with four threads of different priorities that call two static methods performing timed loops. The program output in the console will track each thread's process. Students are also asked to use the Join() method to stop threads until termination.

Uploaded by

Macky Pasyon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
155 views5 pages

04 Task Performance 1

The document provides instructions for an exercise to help students distinguish threads from processes and describe multithreading. It instructs students to create a Windows form program with four threads of different priorities that call two static methods performing timed loops. The program output in the console will track each thread's process. Students are also asked to use the Join() method to stop threads until termination.

Uploaded by

Macky Pasyon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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

You might also like