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
8c848e4a
Commit
8c848e4a
authored
Nov 15, 2023
by
Lenovo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
second step
parent
eed9bea9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
239 additions
and
2 deletions
+239
-2
workspace.xml
.idea/workspace.xml
+38
-2
Summer.java
src/main/java/org/example/summers/Summer.java
+29
-0
SummerCallable.java
src/main/java/org/example/summers/SummerCallable.java
+46
-0
SummerRunnable.java
src/main/java/org/example/summers/SummerRunnable.java
+64
-0
SummerThread.java
src/main/java/org/example/summers/SummerThread.java
+62
-0
No files found.
.idea/workspace.xml
View file @
8c848e4a
...
@@ -4,15 +4,27 @@
...
@@ -4,15 +4,27 @@
<option
name=
"autoReloadType"
value=
"SELECTIVE"
/>
<option
name=
"autoReloadType"
value=
"SELECTIVE"
/>
</component>
</component>
<component
name=
"ChangeListManager"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"2698c064-0a25-4fa9-b373-a085833ed750"
name=
"Changes"
comment=
""
/>
<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>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
<option
name=
"LAST_RESOLUTION"
value=
"IGNORE"
/>
</component>
</component>
<component
name=
"FileTemplateManagerImpl"
>
<option
name=
"RECENT_TEMPLATES"
>
<list>
<option
value=
"Class"
/>
</list>
</option>
</component>
<component
name=
"Git.Settings"
>
<component
name=
"Git.Settings"
>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
<option
name=
"RECENT_GIT_ROOT_PATH"
value=
"$PROJECT_DIR$"
/>
</component>
</component>
<component
name=
"MarkdownSettingsMigration"
>
<option
name=
"stateVersion"
value=
"1"
/>
</component>
<component
name=
"ProjectId"
id=
"2YDqGbLJfns60iFSnvDoXlK7JEf"
/>
<component
name=
"ProjectId"
id=
"2YDqGbLJfns60iFSnvDoXlK7JEf"
/>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"true"
/>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"true"
/>
<component
name=
"ProjectViewState"
>
<component
name=
"ProjectViewState"
>
...
@@ -22,7 +34,8 @@
...
@@ -22,7 +34,8 @@
<component
name=
"PropertiesComponent"
>
<![CDATA[{
<component
name=
"PropertiesComponent"
>
<![CDATA[{
"keyToString": {
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true"
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true"
}
}
}]]>
</component>
}]]>
</component>
<component
name=
"SpellCheckerSettings"
RuntimeDictionaries=
"0"
Folders=
"0"
CustomDictionaries=
"0"
DefaultDictionary=
"application-level"
UseSingleDictionary=
"true"
transferred=
"true"
/>
<component
name=
"SpellCheckerSettings"
RuntimeDictionaries=
"0"
Folders=
"0"
CustomDictionaries=
"0"
DefaultDictionary=
"application-level"
UseSingleDictionary=
"true"
transferred=
"true"
/>
...
@@ -34,6 +47,29 @@
...
@@ -34,6 +47,29 @@
<option
name=
"presentableId"
value=
"Default"
/>
<option
name=
"presentableId"
value=
"Default"
/>
<updated>
1700070404526
</updated>
<updated>
1700070404526
</updated>
</task>
</task>
<task
id=
"LOCAL-00001"
summary=
"first step"
>
<created>
1700070627028
</created>
<option
name=
"number"
value=
"00001"
/>
<option
name=
"presentableId"
value=
"LOCAL-00001"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1700070627028
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"2"
/>
<servers
/>
<servers
/>
</component>
</component>
<component
name=
"Vcs.Log.Tabs.Properties"
>
<option
name=
"TAB_STATES"
>
<map>
<entry
key=
"MAIN"
>
<value>
<State
/>
</value>
</entry>
</map>
</option>
</component>
<component
name=
"VcsManagerConfiguration"
>
<MESSAGE
value=
"first step"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"first step"
/>
</component>
</project>
</project>
\ No newline at end of file
src/main/java/org/example/summers/Summer.java
0 → 100644
View file @
8c848e4a
package
org
.
example
.
summers
;
import
org.example.worker.Worker
;
import
org.example.worker.WorkPartitioner.Part
;
import
java.util.ArrayList
;
import
java.util.List
;
/*
The Summer class is where the primary functions are established.
These functions will be utilized in the future.
*/
public
class
Summer
extends
Worker
{
protected
long
sum
;
public
List
<
Integer
>
getPrimes
()
{
return
primes
;
}
private
List
<
Integer
>
primes
=
new
ArrayList
<>();
public
Summer
(
int
[]
data
,
Part
part
)
{
super
(
data
,
part
);
}
public
long
getSum
()
{
return
sum
;
}
}
src/main/java/org/example/summers/SummerCallable.java
0 → 100644
View file @
8c848e4a
package
org
.
example
.
summers
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
org.example.worker.Worker
;
import
org.example.worker.WorkPartitioner.Part
;
/*
The SummerCallable class is a child of the Summer class and implements the Callable interface.
This class includes a call function that computes the count of prime numbers.
*/
public
class
SummerCallable
extends
Summer
implements
Callable
<
Long
>
{
public
SummerCallable
(
int
[]
data
,
Part
part
)
{
super
(
data
,
part
);
}
@Override
public
Long
call
()
throws
Exception
{
this
.
sum
=
0
;
List
<
Integer
>
primes
=
new
ArrayList
<>();
for
(
int
i
=
start
;
i
<
finish
;
i
++)
{
if
(
isPrime
(
data
[
i
]))
{
primes
.
add
(
data
[
i
]);
sum
++;
}
}
return
sum
;
}
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
;
}
}
\ No newline at end of file
src/main/java/org/example/summers/SummerRunnable.java
0 → 100644
View file @
8c848e4a
package
org
.
example
.
summers
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
org.example.worker.WorkPartitioner.Part
;
/*
The SummerRunnable class is a child of the Summer class and implements the Runnable interface.
This class includes a run function that computes the count of prime numbers.
*/
public
class
SummerRunnable
extends
Summer
implements
Runnable
{
private
Thread
thread
;
private
List
<
Integer
>
primes
=
new
ArrayList
<>();
public
SummerRunnable
(
int
[]
data
,
Part
part
)
{
super
(
data
,
part
);
}
@Override
public
void
run
()
{
sum
=
0
;
for
(
int
i
=
start
;
i
<
finish
;
i
++)
{
if
(
isPrime
(
data
[
i
]))
{
primes
.
add
(
data
[
i
]);
sum
++;
}
}
}
public
void
startThread
()
{
thread
=
new
Thread
(
this
);
thread
.
start
();
}
public
void
joinThread
()
throws
InterruptedException
{
thread
.
join
();
}
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
;
}
@Override
public
List
<
Integer
>
getPrimes
()
{
return
primes
;
}
public
long
getSum
()
{
return
sum
;
}
}
\ No newline at end of file
src/main/java/org/example/summers/SummerThread.java
0 → 100644
View file @
8c848e4a
package
org
.
example
.
summers
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
org.example.worker.WorkPartitioner.Part
;
/*
The SummerThread class is a child of the Thread class.
This class includes a run function that computes the count of prime numbers.
*/
public
class
SummerThread
extends
Thread
{
private
int
start
;
private
int
finish
;
private
int
[]
data
;
private
long
sum
;
private
List
<
Integer
>
primes
=
new
ArrayList
<>();
public
SummerThread
(
int
[]
data
,
int
start
,
int
finish
)
{
this
.
start
=
start
;
this
.
finish
=
finish
;
this
.
data
=
data
;
}
public
SummerThread
(
int
[]
data
,
Part
part
)
{
this
(
data
,
part
.
getStart
(),
part
.
getFinish
());
}
@Override
public
void
run
()
{
sum
=
0
;
for
(
int
i
=
start
;
i
<
finish
;
i
++)
{
if
(
isPrime
(
data
[
i
]))
{
primes
.
add
(
data
[
i
]);
sum
++;
}
}
}
public
long
getSum
()
{
return
sum
;
}
public
List
<
Integer
>
getPrimes
()
{
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
;
}
}
\ No newline at end of file
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