#vulnerable code 
                             void paintLoading(Graphics2D g2d) {
		int w = getWidth(), h = getHeight();
		g2d.setColor(new Color(0, 0, 0, 200));
		g2d.fillRect(0, 0, w, h);
		BufferedImage spinner = _loading.getFrame();
		g2d.drawImage(spinner, null, w / 2 - spinner.getWidth() / 2, h / 2 - spinner.getHeight() / 2);
		repaint();
	} 
                            #location 5 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                             void findTarget(final String patFilename, final Location initOffset) {
		Thread thread = new Thread(new Runnable() {
			@Override
			public void run() {
        Region screenUnion = Region.create(0, 0, 1, 1);
				Finder f = new Finder(_simg, screenUnion);
				try {
					f.find(patFilename);
					if (f.hasNext()) {
//TODO rewrite completely for ScreenUnion
            Screen s = (Screen) screenUnion.getScreen();
            s.setAsScreenUnion();
						_match = f.next();
            s.setAsScreen();
						if (initOffset != null) {
							setTarget(initOffset.x, initOffset.y);
						} else {
							setTarget(0, 0);
						}
					}
					_img = ImageIO.read(new File(patFilename));
				} catch (IOException e) {
					Debug.error(me + "Can't load " + patFilename);
				}
				synchronized (PatternPaneTargetOffset.this) {
					_finding = false;
				}
				repaint();
			}
		});
		thread.start();
	}