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
d800566d
Commit
d800566d
authored
Nov 15, 2023
by
yazan.halloul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sequential Counter commit
parent
3f36db7f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
0 deletions
+61
-0
Main.java
src/main/java/Main.java
+37
-0
SequentialCounter.java
src/main/java/SequentialCounter.java
+24
-0
No files found.
src/main/java/Main.java
0 → 100644
View file @
d800566d
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
;
int
finish
=
10
;
int
[]
data
=
RangeArrayBuilder
.
create
(
start
,
finish
);
for
(
int
d:
data
)
{
System
.
out
.
print
(
d
+
" "
);
}
long
result
=
SequentialCounter
.
findPrimeNumbers
(
data
);
int
threadCount
=
8
;
System
.
out
.
println
(
"\nSequential Prime Number Counter: "
+
result
);
System
.
out
.
println
(
"Parallel Prime Number Counter 0: "
+
ParallelCounter0
.
findPrimeNumbers
(
data
,
8
));
System
.
out
.
println
(
"Parallel Prime Number Counter 1: "
+
ParallelCounter1
.
findPrimeNumbers
(
data
,
8
));
System
.
out
.
println
(
"Parallel Prime Number Counter 2: "
+
ParallelCounter2
.
findPrimeNumbers
(
data
,
8
));
System
.
out
.
println
(
"Parallel Prime Number Counter 3: "
+
ParallelCounter3
.
findPrimeNumbers
(
data
,
8
));
System
.
out
.
println
(
"Parallel Prime Number Counter 4: "
+
ParallelCounter4
.
findPrimeNumbers
(
data
,
8
));
}
}
src/main/java/SequentialCounter.java
0 → 100644
View file @
d800566d
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
)
{
long
numberOfPrimeNumbers
=
0
;
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
if
(
primeChecker
.
isPrime
(
data
[
i
]))
numberOfPrimeNumbers
+=
1
;
}
return
numberOfPrimeNumbers
;
}
}
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