Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31e359ff87 |
Generated
-10
@@ -1,10 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Ignored default folder with query files
|
|
||||||
/queries/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
Generated
-13
@@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<annotationProcessing>
|
|
||||||
<profile name="Maven default annotation processors profile" enabled="true">
|
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
|
||||||
<outputRelativeToContentRoot value="true" />
|
|
||||||
<module name="WS-07-Multithreading-Basics-and-Hashing" />
|
|
||||||
</profile>
|
|
||||||
</annotationProcessing>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Generated
-7
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding">
|
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Generated
-20
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="central" />
|
|
||||||
<option name="name" value="Maven Central repository" />
|
|
||||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="jboss.community" />
|
|
||||||
<option name="name" value="JBoss Community repository" />
|
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="central" />
|
|
||||||
<option name="name" value="Central Repository" />
|
|
||||||
<option name="url" value="https://mirror-maven.runflare.com/maven2" />
|
|
||||||
</remote-repository>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Generated
-12
@@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
|
||||||
<component name="MavenProjectsManager">
|
|
||||||
<option name="originalFiles">
|
|
||||||
<list>
|
|
||||||
<option value="$PROJECT_DIR$/pom.xml" />
|
|
||||||
</list>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="25" project-jdk-type="JavaSDK" />
|
|
||||||
</project>
|
|
||||||
Generated
-6
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -37,40 +37,28 @@ public class Main {
|
|||||||
|
|
||||||
// Split data into 3 parts
|
// Split data into 3 parts
|
||||||
|
|
||||||
int size = data.size();
|
List<String> part1 = null;
|
||||||
|
|
||||||
List<String> part1 = data.subList(0, size / 3);
|
List<String> part2 = null;
|
||||||
List<String> part2 = data.subList(size / 3, 2 * size / 3);
|
|
||||||
List<String> part3 = data.subList(2 * size / 3, size);
|
List<String> part3 = null;
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
|
|
||||||
StudentLoader t1 = new StudentLoader(part1);
|
StudentLoader t1 = null;
|
||||||
|
|
||||||
StudentLoader t2 = new StudentLoader(part2);
|
StudentLoader t2 = null;
|
||||||
|
|
||||||
StudentLoader t3 = new StudentLoader(part3);
|
StudentLoader t3 = null;
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
|
|
||||||
// start()
|
// start()
|
||||||
|
|
||||||
t1.start();
|
|
||||||
t2.start();
|
|
||||||
t3.start();
|
|
||||||
|
|
||||||
// join()
|
// join()
|
||||||
|
|
||||||
t1.join();
|
|
||||||
t2.join();
|
|
||||||
t3.join();
|
|
||||||
|
|
||||||
// merge results
|
// merge results
|
||||||
|
|
||||||
manager.addStudents(t1.getStudents());
|
|
||||||
manager.addStudents(t2.getStudents());
|
|
||||||
manager.addStudents(t3.getStudents());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2 -> {
|
case 2 -> {
|
||||||
@@ -108,4 +96,4 @@ public class Main {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ public class Student {
|
|||||||
// Example:
|
// Example:
|
||||||
// return id % 97;
|
// return id % 97;
|
||||||
|
|
||||||
return id % 97;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,19 +58,13 @@ public class Student {
|
|||||||
// Step 1:
|
// Step 1:
|
||||||
// Check null
|
// Check null
|
||||||
|
|
||||||
if (obj == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 2:
|
// Step 2:
|
||||||
// Convert obj to Student
|
// Convert obj to Student
|
||||||
|
|
||||||
Student student = (Student) obj;
|
|
||||||
|
|
||||||
// Step 3:
|
// Step 3:
|
||||||
// Compare IDs
|
// Compare IDs
|
||||||
|
|
||||||
return this.id == student.id;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ public class StudentManager {
|
|||||||
// Hint:
|
// Hint:
|
||||||
// addAll()
|
// addAll()
|
||||||
|
|
||||||
students.addAll(newStudents);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Student searchStudent(int id) {
|
public Student searchStudent(int id) {
|
||||||
@@ -30,12 +28,6 @@ public class StudentManager {
|
|||||||
|
|
||||||
// Compare IDs
|
// Compare IDs
|
||||||
|
|
||||||
for (Student student : students) {
|
|
||||||
if (student.getId() == id) {
|
|
||||||
return student;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,13 +39,6 @@ public class StudentManager {
|
|||||||
|
|
||||||
// Remove student
|
// Remove student
|
||||||
|
|
||||||
Student student = searchStudent(id);
|
|
||||||
|
|
||||||
if (student != null) {
|
|
||||||
students.remove(student);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,4 +52,4 @@ public class StudentManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package dev.thread;
|
package dev.thread;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import dev.model.Student;
|
import dev.model.Student;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -36,26 +38,15 @@ public class StudentLoader extends Thread {
|
|||||||
// TODO:
|
// TODO:
|
||||||
// split line
|
// split line
|
||||||
|
|
||||||
String[] parts = line.split(",");
|
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// read values
|
// read values
|
||||||
|
|
||||||
int id = Integer.parseInt(parts[0]);
|
|
||||||
String name = parts[1];
|
|
||||||
String major = parts[2];
|
|
||||||
double gpa = Double.parseDouble(parts[3]);
|
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// create Student
|
// create Student
|
||||||
|
|
||||||
Student student = new Student(id, name, major, gpa);
|
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// add to students list
|
// add to students list
|
||||||
|
|
||||||
students.add(student);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -65,4 +56,4 @@ public class StudentLoader extends Thread {
|
|||||||
return students;
|
return students;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,6 @@ public class FileManager {
|
|||||||
|
|
||||||
// Add line to list
|
// Add line to list
|
||||||
|
|
||||||
lines.add(line);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.close();
|
reader.close();
|
||||||
@@ -31,4 +29,4 @@ public class FileManager {
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,3 +22,4 @@ public class Main {
|
|||||||
scanner.close();
|
scanner.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,4 +19,4 @@ public class MyRunnable implements Runnable{
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user