Thread and Executor Service Assignment

From CSE231 Wiki
Revision as of 16:56, 15 February 2022 by Cosgroved (talk | contribs) (→‎Executors)
Jump to navigation Jump to search

Building On Previous Exercises

Be sure to complete the Half & Half and Coarsening exercises first.

Thread

While we strive to make CSE 231 generally applicable across libraries and languages, it would be madness to have a parallel programming class in Java and not have students know how to create a Thread, start it, and join it. In this section of the lab, you will do just that.

Code To Use

interface ThreadFactory

newThread

class Thread

constructor
start
join

As always, the wiki's reference page can be of help.

Code To Implement

DefaultThreadFactory

class: DefaultThreadFactory.java Java.png
methods: newThread
package: threadfactory.exercise
source folder: student/src/main/java

method: public Thread newThread(Runnable target) Sequential.svg (sequential implementation only)

Create and return a new thread with the target Runnable parameter you are passed.

Do *NOT* start this thread.

Certainly, do *NOT* run this thread.

Do not pass Go. Do not collect $200.

To repeat: just create a new Thread with the target Runnable and return it.

ThreadHalfAndHalfNucleobaseCounter

class: ThreadHalfAndHalfNucleobaseCounter.java Java.png
methods: constructor
threadFactory
count
package: count.exercise
source folder: student/src/main/java

constructor

threadFactory

count

method: public int count(byte[] chromosome, Nucleobase targetNucleobase) Parallel.svg (parallel implementation required)

Executors

Code To Use

interface ExecutorService

submit(task)
invokeAll(tasks)

interface Future

get()

NucleobaseCounting

countRangeSequential(chromosome,targetNucleobase,min,maxExclusive)

Ranges

slice​(min, maxExclusive, numRanges).


As always, the wiki's reference page can be of help.


Code To Implement

ExecutorHalfAndHalfNucleobaseCounter

class: ExecutorHalfAndHalfNucleobaseCounter.java Java.png
methods: constructor
executorService
count
package: count.exercise
source folder: student/src/main/java

constructor

executorService

count

method: public int count(byte[] chromosome, Nucleobase targetNucleobase) Parallel.svg (parallel implementation required)

ExecutorCoarseningNucleobaseCounter

class: ExecutorCoarseningNucleobaseCounter.java Java.png
methods: constructor
executorService
numRanges
count
package: count.exercise
source folder: student/src/main/java

constructor

executorService

numRanges

count

method: public int count(byte[] chromosome, Nucleobase targetNucleobase) Parallel.svg (parallel implementation required)

Correctness

class: __ThreadAndExecutorTestSuite.java Junit.png
package: count.exercise
source folder: testing/src/test/java

Pledge, Acknowledgments, Citations

file: thread-and-executor-pledge-acknowledgments-citations.txt

More info about the Honor Pledge