Algorithm Design and Analysis
Assignment One Due 14 October 2022
The purpose of this group assignment is to develop and demonstrate classes that provide pools of threads that can be reused to perform different tasks.
The system should include the following components:
Task which is an abstract base class that implements the Runnable interface and which includes a notifyAll method that the Task can call internally while running to update any registered TaskObserver (interface) method process with progress that the run method wants to report to interested listeners. Each Task instance should receive a unique identifier when it is created from a UniqueIdentifier utility class.
Task<E,F>
+Task(param:E)
+getId():int
+run():void +addListener(o:TaskObserver<F>):void +removeListener(o:TaskObserver<F>):void #notifyAll(progress:F)
(15 marks)
ThreadPool which holds a configurable number of (worker) threads that are used to perform requested Runnable tasks, with each thread returned to the pool (rather than destroyed) once it has completed its task so it can be reused. The following UML diagram can be used as a guide:
ThreadPool
+ThreadPool(initialSize:int)
+getSize():int
+getAvailable():int
+resize(newSize:int):void
+destroyPool():void
+perform(task:Runnable):boolean
A thread in the pool should not consume computer time while there is not a task for it to process, and tasks that can not be performed immediately due to no available worker threads should be held in a queue so that
perform returns immediately. The destroyPool method should ensure all already enqueued tasks are completed before terminating worker threads after which no further tasks can be perfomed by the ThreadPool. (15 marks)
Application which demonstrates an application of using the ThreadPool to process Task that are determined by information received across a TCP or UDP network connection. (15 marks)
Demonstration of features of the system within two weeks of the submission date. (5 marks)
Please indicate to the grader whether each person has agreed to be graded individually for specific features, or whether the overall grade should be split equally.