Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
P
PP-01-Threads-Review
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
mohamadbashar.disoki
PP-01-Threads-Review
Commits
b73274ca
Commit
b73274ca
authored
Oct 18, 2023
by
Mohamad Bashar Desoki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Save Student Service using MultiThread
parent
33f955e5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
16 deletions
+76
-16
workspace.xml
.idea/workspace.xml
+23
-16
StudentServiceTest.java
src/test/java/StudentServiceTest.java
+53
-0
No files found.
.idea/workspace.xml
View file @
b73274ca
...
...
@@ -4,10 +4,8 @@
<option
name=
"autoReloadType"
value=
"SELECTIVE"
/>
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"58d4b7b2-63a8-4164-95ff-e494b5fc28c6"
name=
"Changes"
comment=
"Create Save Student Service"
>
<change
afterPath=
"$PROJECT_DIR$/src/main/java/StudentServiceThread.java"
afterDir=
"false"
/>
<list
default=
"true"
id=
"58d4b7b2-63a8-4164-95ff-e494b5fc28c6"
name=
"Changes"
comment=
"Create Save Student Service using Thread"
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/main/java/StudentService.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/main/java/StudentService.java"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/test/java/StudentServiceTest.java"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/test/java/StudentServiceTest.java"
afterDir=
"false"
/>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
...
@@ -41,16 +39,7 @@
"
last_opened_file_path
"
:
"
D:/HIAST Library/Teaching/PP/2024/lec1/Lec1-Threads
"
}
}
</component>
<component
name=
"RunManager"
selected=
"JUnit.StudentServiceTest.testStudentServiceUsingThread"
>
<configuration
name=
"StudentServiceTest"
type=
"JUnit"
factoryName=
"JUnit"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"Lec1-Threads"
/>
<option
name=
"PACKAGE_NAME"
value=
""
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"StudentServiceTest"
/>
<option
name=
"TEST_OBJECT"
value=
"class"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
<component
name=
"RunManager"
selected=
"JUnit.StudentServiceTest.testStudentServiceUsingThreads"
>
<configuration
name=
"StudentServiceTest.testMultiStudentService"
type=
"JUnit"
factoryName=
"JUnit"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"Lec1-Threads"
/>
<option
name=
"PACKAGE_NAME"
value=
""
/>
...
...
@@ -91,13 +80,23 @@
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
<configuration
name=
"StudentServiceTest.testStudentServiceUsingThreads"
type=
"JUnit"
factoryName=
"JUnit"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"Lec1-Threads"
/>
<option
name=
"PACKAGE_NAME"
value=
""
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"StudentServiceTest"
/>
<option
name=
"METHOD_NAME"
value=
"testStudentServiceUsingThreads"
/>
<option
name=
"TEST_OBJECT"
value=
"method"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
<recent_temporary>
<list>
<item
itemvalue=
"JUnit.StudentServiceTest.testStudentServiceUsingThreads"
/>
<item
itemvalue=
"JUnit.StudentServiceTest.testStudentServiceUsingThread"
/>
<item
itemvalue=
"JUnit.StudentServiceTest.testMultiStudentServiceUsingThreads"
/>
<item
itemvalue=
"JUnit.StudentServiceTest.testMultiStudentService"
/>
<item
itemvalue=
"JUnit.StudentServiceTest.testStudentService"
/>
<item
itemvalue=
"JUnit.StudentServiceTest"
/>
</list>
</recent_temporary>
</component>
...
...
@@ -117,7 +116,14 @@
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1697611342313
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"2"
/>
<task
id=
"LOCAL-00002"
summary=
"Create Save Student Service using Thread"
>
<created>
1697615156687
</created>
<option
name=
"number"
value=
"00002"
/>
<option
name=
"presentableId"
value=
"LOCAL-00002"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1697615156687
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"3"
/>
<servers
/>
</component>
<component
name=
"Vcs.Log.Tabs.Properties"
>
...
...
@@ -133,6 +139,7 @@
</component>
<component
name=
"VcsManagerConfiguration"
>
<MESSAGE
value=
"Create Save Student Service"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"Create Save Student Service"
/>
<MESSAGE
value=
"Create Save Student Service using Thread"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"Create Save Student Service using Thread"
/>
</component>
</project>
\ No newline at end of file
src/test/java/StudentServiceTest.java
View file @
b73274ca
import
junit.framework.TestCase
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
StudentServiceTest
extends
TestCase
{
public
void
testStudentService
()
...
...
@@ -47,4 +50,54 @@ public class StudentServiceTest extends TestCase {
System
.
out
.
println
(
"Time Taken: "
+
end
);
}
public
void
testStudentServiceUsingThreadsNotReally
()
{
long
StartTime
=
System
.
currentTimeMillis
();
StudentService
svc
=
new
StudentService
();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Student
student
=
new
Student
(
"Mhd "
+
i
);
StudentServiceThread
studentServiceThread
=
new
StudentServiceThread
(
svc
,
student
);
studentServiceThread
.
setName
(
"MyTestThread"
+
i
);
studentServiceThread
.
start
();
try
{
studentServiceThread
.
join
();
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
// studentServiceThread.run();
long
end
=
System
.
currentTimeMillis
()-
StartTime
;
System
.
out
.
println
(
"Time Taken: "
+
end
);
}
public
void
testStudentServiceUsingThreads
()
{
long
StartTime
=
System
.
currentTimeMillis
();
StudentService
svc
=
new
StudentService
();
List
<
StudentServiceThread
>
studentServiceThreadList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
Student
student
=
new
Student
(
"Mhd "
+
i
);
StudentServiceThread
studentServiceThread
=
new
StudentServiceThread
(
svc
,
student
);
studentServiceThread
.
setName
(
"MyTestThread"
+
i
);
studentServiceThread
.
start
();
studentServiceThreadList
.
add
(
studentServiceThread
);
}
// studentServiceThread.run();
for
(
StudentServiceThread
studentServiceThread:
studentServiceThreadList
){
try
{
studentServiceThread
.
join
();
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
long
end
=
System
.
currentTimeMillis
()-
StartTime
;
System
.
out
.
println
(
"Time Taken: "
+
end
);
}
}
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