diff --git a/visor.c b/visor.c index b882987..3bf4951 100644 --- a/visor.c +++ b/visor.c @@ -99,17 +99,16 @@ void draw_mandelbrot(struct threadInfo *info) for (int i = a; i < b; i++) { double yRange = (double) i / h * 2.0 - 1.0; double y = centerY+yRange*scale; - for (int j = 0; j < w; j++) { - pthread_mutex_lock(&pixmapMutex); - if (!pixmapAvailable) { - pthread_mutex_unlock(&pixmapMutex); - return; - // after this, the thread will again enter the - // loop in the writer_thread function, and - // enter a wait state - } + pthread_mutex_lock(&pixmapMutex); + if (!pixmapAvailable) { pthread_mutex_unlock(&pixmapMutex); - + return; + // after this, the thread will again enter the + // loop in the writer_thread function, and + // enter a wait state + } + pthread_mutex_unlock(&pixmapMutex); + for (int j = 0; j < w; j++) { double xRange = (double) j / w * 2.0 - 1.0; double x = centerX+xRange*scale;