CIS 636 Spring 2003 Assignment 6 – Simple Threads in Java 100 points
Assigned: 03/17/2003
Due: 03/24/2003 at the start of class
You may work
individually or in pairs for this assignment. But all work must be the work of
the person/people whose name is on the code! If working in pairs, the
individual contributions should be relatively equal. One possibility is to work
together tonight, then finish separately (to avoid communication difficulties).
Main Assignment:
We are going to use related but unsynchronized threads to
work in (sort of) parallel on a problem.
The task is part of a computer-grading application for multiple choice
tests. The task will be divided up
among threads so that each thread works on a particular student’s test paper (A
TestPaper class is provided – and is available on my WWW page under
assignments). Each thread will
calculate the score for the test paper that it is responsible for. The thread code will need to call code from
the TestPaper class; for instance, the TestPaper class provides a method that
does a lot of work for grading a test paper, and access methods that will
enable storing the number correct, incorrect, and pct correct on the test for
the test paper. You task is to 1) write
a class that provides thread capabilities for this task. The class should
include an instance variable to hold a TestPaper that the thread is to work on.
You may set up your threads either extending Thread or implementing
Runnable. 2) write main that a) kludges
up the contents of the correct answers array, and kludges together an array of
test papers to run the threads on (let my student constructor generate the
student’s answers (saves you work)); b) starts a thread for each test paper; c)
retrieves the results from each thread, and d) produces final summary
results.
Once all of the threads have run (make sure all are done!), calculate the high score, low score, and mean score, and how many students were above the mean. Make sure your code will work even with “unlucky” timing.
Hand in:
Miscellaneous:
·
MAKE YOUR WORK
ROBUST!
·
Make sure that your
main demonstrates that your code works.
·
Put YOUR NAME, and
e-mail address in comments at the beginning of the program.
·
Remember: Indentation, meaningful variable names, and
meaningful comments. Weaknesses in any of these could result in points off. You MUST include comments that explain your
program in order to get full credit.