From 6d63d3cea59f0a24ba92bdc5e2d1887284a657d7 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Fri, 5 Jun 2015 15:03:46 +0200 Subject: Version with four swingworkers --- .../src/com/camilstaps/mandelbrot/MandelbrotFractal.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Week15 Mandelbrot/src/com/camilstaps/mandelbrot/MandelbrotFractal.java') 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 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) { -- cgit v1.2.3