For this problem you will use threading to speed up a


Problem

For this problem, you will use threading to speed up a decryption process. There exists a class called Crypt with a static method decrypt. The decrypt method takes a string and returns a non-zero value if the string can be decrypted successfully and 0 otherwise.

You do not need to implement the decrypt method. Its implementation already exists.

The Crypt class takes and array of string keys and the check methods simply calls decrypt on each of those strings, returning immediately if decrypt was successful. See code below. However, the Decrypting is a slow process so you want to convert this to a multithreaded program.

Write a class SuperCrypt that is a subclass of Crypt that can use multiple CPUs to fo decryption concurrently. As always, you are free to add ivars, methods, inner class and so on.

In its constructor, SuperCrypt takes an array of String keys to try. (code provided)

The check() methods should fork off 4 worker threads, Collectively, the workers should try to decrypt all the keys. The check() methods should return 0 if all of the decrypts return 0. If a key decrypts successfully(non-zero), then check() should return its non-zero code. check() should return immediately when a non-zero code is found.

When a successful decrypts is found, we could interrupt() the other workers. However, we will not do this. It is acceptable to allow the other workers to continue to run the completion.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: For this problem you will use threading to speed up a
Reference No:- TGS02909554

Expected delivery within 24 Hours