title: Synchronization Thread Pool ExecutorService
body: <p>this is my first time using thread pools and I dont quite understand how the executorservice works. I put watermarks over an image and merge them onto an empty picture. But even if i only use one thread it will still only draw half.</p>
  
  <p>This is my <strong>WorkerThread class</strong>:</p>
  
  <pre><code>public class WorkerThread implements Runnable {
  
      BufferedImage source;
      BufferedImage toDraw;
      int x;
      int y;
      BufferedImage target;
      ParallelWatermarkFilter pf;
  
      public WorkerThread(BufferedImage source, BufferedImage toDraw, int x, int y, BufferedImage target){
          this.source = source;
          this.toDraw = toDraw;
          this.x = x;
          this.y = y;
          this.target = target;
          pf = new ParallelWatermarkFilter(source, 5);
      }
  
      @Override
      public void run() {
          pf.mergeImages(source, toDraw, x, y, target);
      }
  }
  </code></pre>
  
  <p>And this is is how i use the ExecutorService in my <strong>FilterClass</strong>:</p>
  
  <pre><code>    public BufferedImage apply(BufferedImage input) {
  
          ExecutorService threadpool = Executors.newFixedThreadPool(numThreads);
  
                  for (int w = 0; w &lt; imgWidth; w += watermarkWidth) {
        for (int h = 0; h &lt; imgHeight; h += watermarkHeight) {
              Runnable worker = new WorkerThread(input, watermark, w, h, result);
              System.out.println("WIDTH: " + w + "   HEIGHT: " + h);
              threadpool.execute(worker);
        }
      }
  
      threadpool.shutdown();
  </code></pre>
  
  <p>Do the threads not wait until one thread is done ?</p>