Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
E
Executor_Service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yazan.halloul
Executor_Service
Commits
54d6d1f5
Commit
54d6d1f5
authored
Nov 15, 2023
by
yazan.halloul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final commit
parent
1ee535dc
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
16 additions
and
87 deletions
+16
-87
pom.xml
pom.xml
+14
-0
Main.java
src/main/java/Main.java
+0
-11
SequentialCounter.java
src/main/java/SequentialCounter.java
+0
-10
RangeArrayBuilder.java
src/main/java/data/RangeArrayBuilder.java
+0
-6
ParallelCounter0.java
src/main/java/parallelCounters/ParallelCounter0.java
+0
-7
ParallelCounter1.java
src/main/java/parallelCounters/ParallelCounter1.java
+0
-7
ParallelCounter2.java
src/main/java/parallelCounters/ParallelCounter2.java
+0
-6
ParallelCounter3.java
src/main/java/parallelCounters/ParallelCounter3.java
+0
-8
ParallelCounter4.java
src/main/java/parallelCounters/ParallelCounter4.java
+1
-8
PrimeCounter.java
src/main/java/primeCounters/PrimeCounter.java
+0
-5
PrimeCounterCallable.java
src/main/java/primeCounters/PrimeCounterCallable.java
+0
-6
PrimeCounterRunnable.java
src/main/java/primeCounters/PrimeCounterRunnable.java
+0
-6
PrimeCounterThread.java
src/main/java/primeCounters/PrimeCounterThread.java
+0
-6
ParallelCountersTest.java
src/test/java/ParallelCountersTest.java
+1
-1
No files found.
pom.xml
View file @
54d6d1f5
...
@@ -7,6 +7,20 @@
...
@@ -7,6 +7,20 @@
<groupId>
org.example
</groupId>
<groupId>
org.example
</groupId>
<artifactId>
HW2
</artifactId>
<artifactId>
HW2
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<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>
<properties>
<maven.compiler.source>
17
</maven.compiler.source>
<maven.compiler.source>
17
</maven.compiler.source>
...
...
src/main/java/Main.java
View file @
54d6d1f5
...
@@ -3,18 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
...
@@ -3,18 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import
data.RangeArrayBuilder
;
import
data.RangeArrayBuilder
;
import
parallelCounters.*
;
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
class
Main
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
int
start
=
0
;
int
start
=
0
;
...
...
src/main/java/SequentialCounter.java
View file @
54d6d1f5
import
primeChecker.PrimeChecker
;
import
primeChecker.PrimeChecker
;
/**
* This class provides a method to sequentially calculate the sum of an array.
*
* @author Ahmet Cengizhan Dirican
*/
public
class
SequentialCounter
{
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
();
static
PrimeChecker
primeChecker
=
new
PrimeChecker
();
public
static
long
findPrimeNumbers
(
int
[]
data
)
{
public
static
long
findPrimeNumbers
(
int
[]
data
)
{
...
...
src/main/java/data/RangeArrayBuilder.java
View file @
54d6d1f5
package
data
;
package
data
;
/**
* This class is to produce necessary test data.
*
* @author Ahmet Cengizhan Dirican
*/
public
class
RangeArrayBuilder
{
public
class
RangeArrayBuilder
{
public
static
int
[]
create
(
int
start
,
int
finish
)
{
public
static
int
[]
create
(
int
start
,
int
finish
)
{
...
...
src/main/java/parallelCounters/ParallelCounter0.java
View file @
54d6d1f5
...
@@ -7,13 +7,6 @@ import java.util.List;
...
@@ -7,13 +7,6 @@ import java.util.List;
import
primeCounters.PrimeCounterThread
;
import
primeCounters.PrimeCounterThread
;
import
worker.WorkPartitioner
;
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
class
ParallelCounter0
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
...
...
src/main/java/parallelCounters/ParallelCounter1.java
View file @
54d6d1f5
...
@@ -5,13 +5,6 @@ import java.util.List;
...
@@ -5,13 +5,6 @@ import java.util.List;
import
primeCounters.PrimeCounterRunnable
;
import
primeCounters.PrimeCounterRunnable
;
import
worker.WorkPartitioner
;
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
class
ParallelCounter1
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
...
...
src/main/java/parallelCounters/ParallelCounter2.java
View file @
54d6d1f5
...
@@ -9,12 +9,6 @@ import java.util.concurrent.Executors;
...
@@ -9,12 +9,6 @@ import java.util.concurrent.Executors;
import
primeCounters.PrimeCounterThread
;
import
primeCounters.PrimeCounterThread
;
import
worker.WorkPartitioner
;
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
class
ParallelCounter2
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
...
...
src/main/java/parallelCounters/ParallelCounter3.java
View file @
54d6d1f5
...
@@ -9,14 +9,6 @@ import java.util.concurrent.Future;
...
@@ -9,14 +9,6 @@ import java.util.concurrent.Future;
import
primeCounters.PrimeCounterCallable
;
import
primeCounters.PrimeCounterCallable
;
import
worker.WorkPartitioner
;
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
class
ParallelCounter3
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
...
...
src/main/java/parallelCounters/ParallelCounter4.java
View file @
54d6d1f5
...
@@ -8,14 +8,7 @@ import java.util.concurrent.Future;
...
@@ -8,14 +8,7 @@ import java.util.concurrent.Future;
import
primeCounters.PrimeCounterCallable
;
import
primeCounters.PrimeCounterCallable
;
import
primeCounters.PrimeCounterThread
;
import
primeCounters.PrimeCounterThread
;
import
worker.WorkPartitioner
;
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
*/
public
class
ParallelCounter4
{
public
class
ParallelCounter4
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
public
static
long
findPrimeNumbers
(
int
[]
data
,
int
threadCount
)
{
...
...
src/main/java/primeCounters/PrimeCounter.java
View file @
54d6d1f5
...
@@ -3,11 +3,6 @@ package primeCounters;
...
@@ -3,11 +3,6 @@ package primeCounters;
import
worker.WorkPartitioner.Part
;
import
worker.WorkPartitioner.Part
;
import
worker.Worker
;
import
worker.Worker
;
/**
* Base summer/worker class to calculate the sum of an array.
*
* @author Ahmet Cengizhan Dirican
*/
public
class
PrimeCounter
extends
Worker
{
public
class
PrimeCounter
extends
Worker
{
protected
long
numberOfPrimeNumbers
;
protected
long
numberOfPrimeNumbers
;
public
PrimeCounter
(
int
[]
data
,
Part
part
)
{
public
PrimeCounter
(
int
[]
data
,
Part
part
)
{
...
...
src/main/java/primeCounters/PrimeCounterCallable.java
View file @
54d6d1f5
...
@@ -4,12 +4,6 @@ import java.util.concurrent.Callable;
...
@@ -4,12 +4,6 @@ import java.util.concurrent.Callable;
import
primeChecker.PrimeChecker
;
import
primeChecker.PrimeChecker
;
import
worker.WorkPartitioner.Part
;
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
>
{
public
class
PrimeCounterCallable
extends
PrimeCounter
implements
Callable
<
Long
>
{
PrimeChecker
primeChecker
=
new
PrimeChecker
();
PrimeChecker
primeChecker
=
new
PrimeChecker
();
...
...
src/main/java/primeCounters/PrimeCounterRunnable.java
View file @
54d6d1f5
...
@@ -3,12 +3,6 @@ package primeCounters;
...
@@ -3,12 +3,6 @@ package primeCounters;
import
primeChecker.PrimeChecker
;
import
primeChecker.PrimeChecker
;
import
worker.WorkPartitioner.Part
;
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
{
public
class
PrimeCounterRunnable
extends
PrimeCounter
implements
Runnable
{
PrimeChecker
primeChecker
=
new
PrimeChecker
();
PrimeChecker
primeChecker
=
new
PrimeChecker
();
...
...
src/main/java/primeCounters/PrimeCounterThread.java
View file @
54d6d1f5
...
@@ -3,12 +3,6 @@ package primeCounters;
...
@@ -3,12 +3,6 @@ package primeCounters;
import
primeChecker.PrimeChecker
;
import
primeChecker.PrimeChecker
;
import
worker.WorkPartitioner.Part
;
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
{
public
class
PrimeCounterThread
extends
Thread
{
PrimeChecker
primeChecker
=
new
PrimeChecker
();
PrimeChecker
primeChecker
=
new
PrimeChecker
();
...
...
src/test/java/ParallelCountersTest.java
View file @
54d6d1f5
...
@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test;
...
@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test;
import
parallelCounters.*
;
import
parallelCounters.*
;
class
ParallelCountersTest
{
class
ParallelCountersTest
{
private
static
int
start
;
private
static
int
start
;
s
private
static
int
finish
;
private
static
int
finish
;
private
static
int
[]
data
;
private
static
int
[]
data
;
private
static
long
result
;
private
static
long
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment