diff options
author | Camil Staps | 2015-06-05 15:03:46 +0200 |
---|---|---|
committer | Camil Staps | 2015-06-05 15:03:46 +0200 |
commit | 6d63d3cea59f0a24ba92bdc5e2d1887284a657d7 (patch) | |
tree | dcfc15a8afaa3b01c8d7de9d93bbdcb2f31cd8a3 /Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java | |
parent | Everything works except for multiple swingworkers (diff) |
Version with four swingworkers
Diffstat (limited to 'Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java')
-rw-r--r-- | Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java b/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java index 1c608fd..43909fe 100644 --- a/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java +++ b/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java @@ -39,12 +39,12 @@ public class MandelbrotFractal { */ private static final Map<Point,Result> mandelNumbers = new HashMap<>(); - public static int mandelNumber(double x, double y, int repetitions) { + public synchronized static int mandelNumber(double x, double y, int repetitions) { Point p = new Point(x, y); return mandelNumber(p, repetitions); } - public static int mandelNumber(Point p, int repetitions) { + public synchronized static int mandelNumber(Point p, int repetitions) { if (mandelNumbers.containsKey(p)) { Result result = mandelNumbers.get(p); if (repetitions < result.repetitions || @@ -61,7 +61,7 @@ public class MandelbrotFractal { } } - protected static Result calculateMandelNumber(Point p, int repetitions) { + protected synchronized static Result calculateMandelNumber(Point p, int repetitions) { Result start = new Result(); start.x = p.x; start.y = p.y; @@ -69,7 +69,7 @@ public class MandelbrotFractal { return start; } - protected static void calculateMandelNumber(Point p, int repetitions, Result start) { + protected synchronized static void calculateMandelNumber(Point p, int repetitions, Result start) { int n = start.repetitions; while (start.x * start.x + start.y * start.y <= 4 && n < repetitions) { |