Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
E
ExecutorServiceHW
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
laith.asaad
ExecutorServiceHW
Commits
facfc59b
Commit
facfc59b
authored
Nov 15, 2023
by
Lenovo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fourth step with main tester
parent
d57be0bb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
7 deletions
+89
-7
workspace.xml
.idea/workspace.xml
+19
-5
pom.xml
pom.xml
+13
-1
Main.java
src/main/java/org/example/Main.java
+18
-1
SequentialSummer.java
src/main/java/org/example/SequentialSummer.java
+39
-0
No files found.
.idea/workspace.xml
View file @
facfc59b
...
...
@@ -4,9 +4,7 @@
<option
name=
"autoReloadType"
value=
"SELECTIVE"
/>
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"2698c064-0a25-4fa9-b373-a085833ed750"
name=
"Changes"
comment=
"first step"
>
<change
afterPath=
"$PROJECT_DIR$/src/main/java/org/example/summers/Summer.java"
afterDir=
"false"
/>
</list>
<list
default=
"true"
id=
"2698c064-0a25-4fa9-b373-a085833ed750"
name=
"Changes"
comment=
"third step"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
...
...
@@ -54,7 +52,21 @@
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1700070627028
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"2"
/>
<task
id=
"LOCAL-00002"
summary=
"second step"
>
<created>
1700070804720
</created>
<option
name=
"number"
value=
"00002"
/>
<option
name=
"presentableId"
value=
"LOCAL-00002"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1700070804720
</updated>
</task>
<task
id=
"LOCAL-00003"
summary=
"third step"
>
<created>
1700071001900
</created>
<option
name=
"number"
value=
"00003"
/>
<option
name=
"presentableId"
value=
"LOCAL-00003"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1700071001900
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"4"
/>
<servers
/>
</component>
<component
name=
"Vcs.Log.Tabs.Properties"
>
...
...
@@ -70,6 +82,8 @@
</component>
<component
name=
"VcsManagerConfiguration"
>
<MESSAGE
value=
"first step"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"first step"
/>
<MESSAGE
value=
"second step"
/>
<MESSAGE
value=
"third step"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"third step"
/>
</component>
</project>
\ No newline at end of file
pom.xml
View file @
facfc59b
...
...
@@ -7,7 +7,19 @@
<groupId>
org.example
</groupId>
<artifactId>
ExecutorServiceHW
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.13.2
</version>
</dependency>
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter
</artifactId>
<version>
RELEASE
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>
17
</maven.compiler.source>
<maven.compiler.target>
17
</maven.compiler.target>
...
...
src/main/java/org/example/Main.java
View file @
facfc59b
package
org
.
example
;
import
org.example.data.TestData
;
import
org.example.parallelsummers.*
;
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Hello world!"
);
/*
Use Main function to make unit testing
*/
int
start
=
0
;
int
end
=
20
;
int
[]
data
=
TestData
.
createData
(
start
,
end
);
long
result
=
SequentialSummer
.
sum
(
SequentialSummer
.
allPrimes
(
data
));
System
.
out
.
println
(
"result is "
+
result
);
int
threadCount
=
25
;
System
.
out
.
println
(
"Sequential summer:"
+
result
);
System
.
out
.
println
(
"Parallel summer 1: "
+
ParallelSummer0
.
sum
(
data
,
threadCount
));
System
.
out
.
println
(
"Parallel summer 2: "
+
ParallelSummer1
.
sum
(
data
,
threadCount
));
System
.
out
.
println
(
"Parallel summer 3: "
+
ParallelSummer2
.
sum
(
data
,
threadCount
));
System
.
out
.
println
(
"Parallel summer 4: "
+
ParallelSummer3
.
sum
(
data
,
threadCount
));
System
.
out
.
println
(
"Parallel summer 5: "
+
ParallelSummer4
.
sum
(
data
,
threadCount
));
}
}
\ No newline at end of file
src/main/java/org/example/SequentialSummer.java
0 → 100644
View file @
facfc59b
package
org
.
example
;
import
java.util.ArrayList
;
import
java.util.List
;
/*
The SequentialSummer class calculate the number of primes sequentially.
*/
public
class
SequentialSummer
{
public
static
long
sum
(
List
<
Integer
>
data
)
{
long
sum
=
data
.
size
();
return
sum
;
}
/*
The allPrimes function find all primes in the data array sequentially using isPrime function.
*/
public
static
List
<
Integer
>
allPrimes
(
int
[]
data
)
{
List
<
Integer
>
primes
=
new
ArrayList
<>();
for
(
int
i
=
data
[
0
];
i
<=
data
[
data
.
length
-
1
];
i
++)
{
if
(
isPrime
(
i
))
{
primes
.
add
(
i
);
}
}
return
primes
;
}
private
static
boolean
isPrime
(
int
num
)
{
if
(
num
<=
1
)
{
return
false
;
}
for
(
int
i
=
2
;
i
*
i
<=
num
;
i
++)
{
if
(
num
%
i
==
0
)
{
return
false
;
}
}
return
true
;
}
}
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