Executors

Overview

For this project you will write a client-server program to test several of ExecutorService-based server implementations. You will make four implementations of the following Java Interface:

public interface ServerInterface {
    /** See java.util.concurrent.Future<String>.get() for documentation
     *  on return value and exceptions thrown.
     *  @param task is the task to run in the server via task.call().
    **/
    public Integer submit(Callable<Integer> task)
        throws CancellationException, // if the computation was cancelled
            ExecutionException, // if the computation threw an exception
            InterruptedException // if the server thread was interrupted
        ;

    /**
     *  Shut down the server. Applications must generally shut down a
     *  server to terminate the process, since the server uses non-daemon
     *  threads.
     *  @param force if false use ExecutorService.shutdown(), and
     *  if true use ExecutorService.shutdownNow().
    **/
    public void shutdown(boolean force);
}

The implementations use the following thread pool methods:

The driver program must take the following command line arguments, in this specific order:

The general flow of the driver program is:

Example output:

$ java -cp .. project4.Main 4 NoThreadPool 5 42
Client 0 result[0] = 121393
Client 0 result[1] = 196418
Client 0 result[2] = 0
Client 0 result[3] = 6765
Client 0 result[4] = 2584
Client 1 result[0] = 121393
Client 1 result[1] = 196418
Client 1 result[2] = 0
Client 1 result[3] = 6765
Client 1 result[4] = 2584
Client 2 result[0] = 121393
Client 2 result[1] = 196418
Client 2 result[2] = 0
Client 2 result[3] = 6765
Client 2 result[4] = 2584
Client 3 result[0] = 121393
Client 3 result[1] = 196418
Client 3 result[2] = 0
Client 3 result[3] = 6765
Client 3 result[4] = 2584

Turning in the Assignment

For this assignment, you must turn in a zip file of a directory named project4 containing the following:

Submit the zip file to the appropriate folder on D2L.

Total Points: 50

Program Correctness (20 points)

This evaluates whether your program works as intended. It is based on the results of automated tests that check if your code implements all required functionality correctly. This category also includes any additional issues not explicitly tested but that might lead to incorrect behavior.

Program Design (15 points)

This evaluates the overall structure and organization of your code. A well-designed program will typically have:

Code Readability & Style (5 points)

This evaluates how easy it is to read and understand your code, as well as how well you adhere to the style guide. The key points to consider are:

Documentation & Comments (5 points)

This measures how well your code is documented. At a minimum, your code should:

Adherence to Additional Specifications (5 points)

This checks whether you’ve followed all other requirements outside the coding task itself. For example:

Important Notes: