mirror of
https://github.com/RustyRaptor/parallel-programming.git
synced 2026-12-03 15:55:15 -07:00
started openmp project
This commit is contained in:
1 parent
acbb814247
commit
e95d902dda
4 files changed
+63
-32
No files matched your search
Binary file not shown.
@@ -1,7 +1,8 @@
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class CountThrees implements Runnable {
|
||||
private static final int ARRAY_LENGTH = 1000000;
|
||||
private static int ARRAY_LENGTH;
|
||||
private static final int MAX_THREADS = 10;
|
||||
private static final int MAX_RANGE = 100;
|
||||
private static final Random random = new Random();
|
||||
@@ -11,6 +12,16 @@ public class CountThrees implements Runnable {
|
||||
private static Thread[] threads;
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length != 1) {
|
||||
System.err.println("Usage: java CountThrees <array_length>");
|
||||
System.exit(1);
|
||||
}
|
||||
try {
|
||||
ARRAY_LENGTH = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Invalid argument: " + args[0] + " is not a valid integer");
|
||||
System.exit(1);
|
||||
}
|
||||
array = new int[ARRAY_LENGTH];
|
||||
|
||||
// Initialize the elements in the array
|
||||
@@ -78,4 +89,4 @@ public class CountThrees implements Runnable {
|
||||
count += myCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
all: CountThrees.class run
|
||||
all: CountThrees.class
|
||||
|
||||
CountThrees.class:
|
||||
javac CountThrees.java
|
||||
run:
|
||||
java CountThrees
|
||||
java CountThrees 1000000000
|
||||
clean:
|
||||
rm -f CountThrees.class
|
||||
Reference in new issue
Block a user