-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathMain.java
69 lines (60 loc) · 2.17 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package mandelbrot;
/**
* Main class in the Mandelbrot project. This will eventually, begin threads to
* create different images of the Mandelbrot set.
* @author Eric Mosher
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// The number of threads to use. We will use 4 because I have a
// Quad-core processor. (Intel i5)
int numThreads = 4;
// The threads used in this program
Thread[] threads = new Thread[numThreads];
// The number of pictures per thread
int picsPerThread = 3;
// The names of the files will be mbrot1, mbrot2, etc.
String fName = "mbrot";
// The number we will attach to the file name
int count = 1;
// The beginning resolution
int resolution = 500;
// The image center
double xCenter = -0.38;
double yCenter = -0.665;
// Number of total iterations
int maxIterations = 1000;
ColorScheme color = new ColorScheme(maxIterations);
// For the number of threads being used...
for (int a = 0; a < numThreads; a++) {
// Create an array to give to each thread
MbrotParameter[] mbrots = new MbrotParameter[picsPerThread];
// For every parameter in the array...
for (int b = 0; b < picsPerThread; b++) {
// Create the parameter and assign it to the place in the array
mbrots[b] = new MbrotParameter(fName + String.valueOf(count),
resolution, xCenter, yCenter);
// Update our data
count++;
resolution += 1000;
}
// Create a new thread with the appropriate array as the parameter.
threads[a] = new Thread(new MandelbrotRenderer(mbrots, color,
maxIterations));
}
// Start the threads
for (Thread t : threads) {
t.start();
}
// Join the threads
for (Thread t : threads) {
try {
t.join();
}
catch (Exception e) {}
}
}
}