First, create a lab05 directory:
$ cd cs190m $ mkdir lab05 $ cd lab05
Then, download Lab05Thread.java into the folder you just created.
Recall that having a class extend Thread means that it needs to override the run() method, which has no parameters. This means that when you create an object of this type, it needs to have a constructor that takes in necessary data. This means that you should create a constructor that takes in the encryption matrix and the part of the plaintext that will be encrypted. The run() method will look similar to the sequential execution that you did last week.
You'll also need to change the transform() method. Instead of sequentially encrypting blocks of the plaintext, it should instead divide the plaintext into blocks and spawn the required number of threads (specified by the numThreads parameter) with the proper data and then start them. Of course, it has to join() them before retrieving the results of the encryption.
See how well your threaded implementation stacks up against the sequential version that you wrote last week. Of course, the test string given to you is much too short. A test class is provided with test files below. The tester only tests up to 4 threads of execution, but it may be interesting to see if execution time changes with more than 4 threads.
To turn in your lab:
$ cd ~/cs190m/lab05 $ turnin -v -c cs190m -p lab05 *.java
Many of you will probably run across problems while programming at some point during a lab. If that's the case, here are the resources you should use, in order:
Lab created by: Daniel Tang