Commit 54d6d1f5 authored by yazan.halloul's avatar yazan.halloul

Final commit

parent 1ee535dc
......@@ -7,6 +7,20 @@
<groupId>org.example</groupId>
<artifactId>HW2</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>17</maven.compiler.source>
......
......@@ -3,18 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import data.RangeArrayBuilder;
import parallelCounters.*;
//import parallelsummers.ParallelSummer2;
/**
* This projects is indented to show different ways of parallel programming in java
* in terms of
* # designing workers
* # executing them
* # getting and combining the results
*
* @author Ahmet Cengizhan Dirican
*/
public class Main {
public static void main(String[] args) {
int start = 0;
......
import primeChecker.PrimeChecker;
/**
* This class provides a method to sequentially calculate the sum of an array.
*
* @author Ahmet Cengizhan Dirican
*/
public class SequentialCounter {
/**
* Returns the sum of all the element of a given array.
* @param data the integer array
* @return the sum
*/
static PrimeChecker primeChecker = new PrimeChecker();
public static long findPrimeNumbers(int[] data) {
......
package data;
/**
* This class is to produce necessary test data.
*
* @author Ahmet Cengizhan Dirican
*/
public class RangeArrayBuilder {
public static int[] create(int start, int finish) {
......
......@@ -7,13 +7,6 @@ import java.util.List;
import primeCounters.PrimeCounterThread;
import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterThread} and conventional thread
* start and join mechanisms.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter0 {
public static long findPrimeNumbers(int[] data, int threadCount) {
......
......@@ -5,13 +5,6 @@ import java.util.List;
import primeCounters.PrimeCounterRunnable;
import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterRunnable} and conventional thread
* start and join mechanisms placed into {@link PrimeCounterRunnable}.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter1 {
public static long findPrimeNumbers(int[] data, int threadCount) {
......
......@@ -9,12 +9,6 @@ import java.util.concurrent.Executors;
import primeCounters.PrimeCounterThread;
import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterThread} and {@link ExecutorService}
* with a fixed thread pool. The class executes the threads one bye one.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter2 {
public static long findPrimeNumbers(int[] data, int threadCount) {
......
......@@ -9,14 +9,6 @@ import java.util.concurrent.Future;
import primeCounters.PrimeCounterCallable;
import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterCallable} and {@link ExecutorService}
* with a fixed thread pool. The class invokes all the callables at once.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter3 {
public static long findPrimeNumbers(int[] data, int threadCount) {
......
......@@ -8,14 +8,7 @@ import java.util.concurrent.Future;
import primeCounters.PrimeCounterCallable;
import primeCounters.PrimeCounterThread;
import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterThread} and {@link ExecutorService}
* with a fixed thread pool. The class submits the threads one bye one for executions.
*
* @author Ahmet Cengizhan Dirican
*/
import worker.WorkPartitioner;
public class ParallelCounter4 {
public static long findPrimeNumbers(int[] data, int threadCount) {
......
......@@ -3,11 +3,6 @@ package primeCounters;
import worker.WorkPartitioner.Part;
import worker.Worker;
/**
* Base summer/worker class to calculate the sum of an array.
*
* @author Ahmet Cengizhan Dirican
*/
public class PrimeCounter extends Worker {
protected long numberOfPrimeNumbers;
public PrimeCounter(int[] data, Part part) {
......
......@@ -4,12 +4,6 @@ import java.util.concurrent.Callable;
import primeChecker.PrimeChecker;
import worker.WorkPartitioner.Part;
/**
* {@link Callable} based {@link PrimeCounter ).
*
* @author Ahmet Cengizhan Dirican
* @see https://github.com/acdirican
*/
public class PrimeCounterCallable extends PrimeCounter implements Callable<Long> {
PrimeChecker primeChecker = new PrimeChecker();
......
......@@ -3,12 +3,6 @@ package primeCounters;
import primeChecker.PrimeChecker;
import worker.WorkPartitioner.Part;
/**
* {@link Runnable} based {@link PrimeCounter ).
*
* @author Ahmet Cengizhan Dirican
* @see https://github.com/acdirican
*/
public class PrimeCounterRunnable extends PrimeCounter implements Runnable{
PrimeChecker primeChecker = new PrimeChecker();
......
......@@ -3,12 +3,6 @@ package primeCounters;
import primeChecker.PrimeChecker;
import worker.WorkPartitioner.Part;
/**
* {@link Thread} based summer/worker Because this class cannot extends the {@link PrimeCounter},
* it had to include the similar code.
*
* @author Ahmet Cengizhan Dirican
*/
public class PrimeCounterThread extends Thread{
PrimeChecker primeChecker = new PrimeChecker();
......
......@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test;
import parallelCounters.*;
class ParallelCountersTest {
private static int start;
private static int start;s
private static int finish;
private static int[] data;
private static long result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment