CSE647: Testing and Verification Homework 1 (ver. 7 Sep) Due 14 Sep Scott Stoller This assignment explores whether scheduling in JDK1.2.1 is deterministic. We will run a concurrent program that deliberately lacks appropriate synchronization and see how often this error manifests itself in incorrect behavior. Some parts of the assignment are just for practice with Java. Most of the code is provided on the course web page. Use /usr/bin/javac to compile the program: javac hw1.java Use /usr/bin/java to run the program: java hw1 To make sure you are getting the right version, run java -version It should say java version "1.2.1" Solaris VM (build Solaris_JDK_1.2.1_02, native threads, sunwjit) 1. Set numThreads to 2. Run the program 30 times. For convenience, use the shell script hw1-run provided on the course web page. In what percentage of the runs does the lack of synchronization manifest itself as an error? 2. Repeat step 2, except with numThreads equal to 3. 3. Modify the program so that Worker implements Runnable and does not extend Thread. This requires changing 2 lines of code. Change class Worker implements Runnable { to class Worker extends Thread { You also need to change the line (new Worker(shared)).start(); What should you change it to? Hint: Read the documentation for java.lang.Thread in the Java 2 API. 4. Is the program guaranteed to print the final list exactly once? If so, explain why. If not, explain why and modify the program so that it is guaranteed to do so.