C SC 340 Project 2: Multithreaded Java Matrix Multiplication
Spring 2009
Due: before start of lab period Thursday April 23
Worth 15 points
This assignment will gently introduce you to user threads provided by Java. You will solve the Matrix Multiplication project described at the end of Chapter 4 beginning on page 162. Do only the Java solution! Although I am giving you this assignment prior to our lecture discussion of threads, you can proceed because it includes non-threads programming that you should do first.
Again, follow the "individual with partner" approach. Feel free to help and advise each other but produce an individual solution.
File Format: A matrix data file is a text file consisting of all integer values formatted something like this
R | C | ||
M11 | M12 | ... | M1C |
M21 | M22 | ... | M2C |
... | ... | ... | ... |
MR1 | MR2 | ... | MRC |
R is the number of rows, C is the number of columns, and the M's are the data themselves. All numbers are separated by one or more spaces. This format is used for both reading and writing a matrix. If you need a quick refresher on Java file I/O, see my posted CSC 160 lecture notes.
Here are example contents of a text file containing such a matrix:2 | 3 | |
27 | -8 | 15 |
36 | 94 | -526 |
Using your Program:
Robustness: Besides the matrix dimension mismatch described above, your program should also deal with the problem of non-existing input files - this should result in an error message followed by program termination. You may assume that the contents of input files are correctly formatted. If the output file already exists, have the user confirm before overwriting it (for confirmation input, use either the Scanner class in java.util or the static JOptionPane.showConfirmDialog() method in javax.swing - it does not require a frame if you use null for the first argument).
Documentation: Each of your classes and methods needs to be appropriately documented with comments. Make sure your name is at the top of each file.
Threads: Refer to the textbook problem description for information about how threads are to be used in your solution. I will add one additional requirement: the thread class must implement Runnable, not extend Thread. This topic is covered in my threads lecture notes. For your reference, Java 2 Standard Edition API documentation is found at http://math.otterbein.edu/home/java/j2sdk1.5/docs/api/