Assignment
Due at the beginning of class on Wednesday, October 22
Preparation
Use the same program from last week, found here.
Recall that this program works as follows
- a file, quickBrownFoxIn.txt (provided in the zip file) is opened for input. This file has lots of lines of text that all look the same.
- a second file, quickBrownFoxOut.txt (provided in the zip file) is opened for output. This file is initially empty.
- two threads are then started. Each thread does the same thing. It opens reads a character from quickBrownFoxIn.txt and writes that character to quickBrownFoxOut.txt.
What you did last week
- unzip the file
- open quickBrownFoxIn.txt in Notepad or some other text viewer to see what it looks like
- run the program
- open quickBrownFoxOut.txt in Notepad or some other text viewer to see what it looks like
To Do this week
Using Java features for synchronizing threads, modify the program so that the output file will look like the input file in every case. Note that the purpose is NOT to rewrite the program in some fashion so that it works, but rather to leave the program design as is, but add synchronization structures to ensure that the resulting output file is guaranteed to have no anomalies.
To Turn In
Turn in this information:
- Your program with the code that you added highlighted.
- A description of what this modification does to ensure that synchronization is ensured.