Assignment 1 for COP 4610L Operating Systems Course - Thread Synchronization, Assignments of Computer Science

Instructions for assignment 1 of the cop 4610l operating systems course, focusing on thread synchronization using java. Students are required to research the setname() and join() thread methods, assign a name to the timerthread using setname() in the constructor, display the name of the timethread, modify the animate class stop() method to use join() method for thread termination synchronization, and create 10 jpeg images for the program. Sample java code for timerthread and animate applet classes.

Typology: Assignments

Pre 2010

Uploaded on 11/08/2009

koofers-user-ezl
koofers-user-ezl 🇺🇸

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COP 4610L – Operating Systems
Assignment 1
Due Wednesday May 29, 2002
Dr. Denver Williams
ENGR 440
407-823-4964
www.cs.ucf.edu/~dwilliam
Summer 2002
Office Hours
Wednesday 3:00-4:00. Also by appointment. I will try to answer e-mail questions in a timely manner; concise
questions are likely to elicit quicker responses.
Instructions
Please work independently.
Please turn in your work via email to the grader: [email protected]
There will be no make up exams, assignments, or tests.
1. Research the following two Thread methods
a. setName()
b. join()
2. Use the setName method to assign a name to the TimerThread. Do this in the TimerThread constructor
3. In the Applet class, display the name of the TimeThread immediately after the TimerThread has been
instantiated.
4. Modify the Animate class stop() method to use the Thread join() method to synchronize the termination of
the TimerThread().
5. To run the program, you need to create 10 jpeg images in the directory where the program is. Name the
images 0.jpeg, 2.jpeg, …, 9.jpeg.
You are to turn in the modified java classes.
pf3

Partial preview of the text

Download Assignment 1 for COP 4610L Operating Systems Course - Thread Synchronization and more Assignments Computer Science in PDF only on Docsity!

COP 4610L – Operating Systems

Assignment 1 Due Wednesday May 29, 2002

Dr. Denver Williams ENGR 440 407-823- [email protected] www.cs.ucf.edu/~dwilliam

Summer 2002

Office Hours

Wednesday 3:00-4:00. Also by appointment. I will try to answer e-mail questions in a timely manner; concise questions are likely to elicit quicker responses.

Instructions

Please work independently. Please turn in your work via email to the grader: [email protected] There will be no make up exams, assignments, or tests.

  1. Research the following two Thread methods a. setName() b. join()
  2. Use the setName method to assign a name to the TimerThread. Do this in the TimerThread constructor
  3. In the Applet class, display the name of the TimeThread immediately after the TimerThread has been instantiated.
  4. Modify the Animate class stop() method to use the Thread join() method to synchronize the termination of the TimerThread().
  5. To run the program, you need to create 10 jpeg images in the directory where the program is. Name the images 0.jpeg, 2.jpeg, …, 9.jpeg.

You are to turn in the modified java classes.

The sample program is below.

// TimerThread class

import java.awt.*;

public class TimerThread extends Thread

Component m_comp; // Component that needs repainting

int m_timeDiff; // Time between repaints of the component

volatile boolean m_shouldRun // Set to false to stop thread

public TimerThread(Component comp, int timeDiff)

m_comp = comp;

m_timeDiff = timeDiff;

m_shouldRun = true;

public void run()

while (m_shouldRun)

try

m_comp.repaint();

sleep(m_timeDiff);

catch (Exception e)