package org.helioviewer.jhv.display;

import java.util.ArrayList;

public class Displayer{
	
    private static Displayer instance = new Displayer();
    private final ArrayList<DisplayListener> listeners = new ArrayList<DisplayListener>();
    private final ArrayList<RenderListener> renderListeners = new ArrayList<RenderListener>();
    private GL3DComponentFakeInterface gl3dcomponent;
	private Object lock = new Object();
	private int queue = 0;

    public void register(GL3DComponentFakeInterface gl3dcomponent){
    	this.gl3dcomponent = gl3dcomponent;
    }
	public static Displayer getSingletonInstance() {
        if (instance == null) {
            throw new NullPointerException("Displayer not initialized");
        }
        return instance;
    }
    public void addListener(final DisplayListener listener) {
        listeners.add(listener);
    }
    
    public void removeListener(final DisplayListener renderListener) {
    	synchronized(renderListener){
    		listeners.remove(renderListener);
    	}
    }
    public void addRenderListener(final RenderListener renderListener) {
    	synchronized(renderListener){
    		renderListeners.add(renderListener);
    	}
    }
    public void removeRenderListener(final RenderListener listener) {
    	synchronized(renderListeners){
    		renderListeners.remove(listener);
    	}
    }    
    public void render(){
    	synchronized(renderListeners){
	        for(final RenderListener renderListener : renderListeners) {
	        	renderListener.render();
	        }
    	}
    }

    public void display(){
    	int queuecopy;
    	synchronized(lock ){
    		queue ++;
    		queuecopy=queue;
    	}
    	if(queuecopy==1){
    		while(queue>0){

    	    	synchronized(listeners){
			        for(final DisplayListener listener : listeners) {
			            listener.display();
			        }
    	    	}
		    	queue--;
	    	}
    	}
    }
    public void animate(){
    	gl3dcomponent.activate();
    }
    public void stopAnimate(){

    	gl3dcomponent.deactivate();
    }
}

package org.helioviewer.jhv.display;

import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Displayer{
	
	private static Displayer instance = new Displayer();
    private final ArrayList<DisplayListener> listeners = new ArrayList<DisplayListener>();
    private final ArrayList<RenderListener> renderListeners = new ArrayList<RenderListener>();
    private GL3DComponentFakeInterface gl3dcomponent;
    private ExecutorService displayPool = Executors.newSingleThreadExecutor();

    public void register(GL3DComponentFakeInterface gl3dcomponent){
    	this.gl3dcomponent = gl3dcomponent;
    }
	public static Displayer getSingletonInstance() {
        if (instance == null) {
            throw new NullPointerException("Displayer not initialized");
        }
        return instance;
    }
    public void addListener(final DisplayListener listener) {
        listeners.add(listener);
    }
    
    public void removeListener(final DisplayListener renderListener) {
    	synchronized(renderListener){
    		listeners.remove(renderListener);
    	}
    }
    public void addRenderListener(final RenderListener renderListener) {
    	synchronized(renderListener){
    		renderListeners.add(renderListener);
    	}
    }
    public void removeRenderListener(final RenderListener listener) {
    	synchronized(renderListeners){
    		renderListeners.remove(listener);
    	}
    }    
    public void render(){
    	synchronized(renderListeners){
	        for(final RenderListener renderListener : renderListeners) {
	        	renderListener.render();
	        }
    	}
    }
    private void tdisplay(){
    	synchronized(listeners){
	        for(final DisplayListener listener : listeners) {
	            listener.display();
	        }
    	}
    }
    private final class DisplayTask implements Runnable{
		@Override
		public void run() {
			tdisplay();
		}
    }
    public void display(){
    	displayPool.submit(new DisplayTask());
    }
   
    public void animate(){
    	gl3dcomponent.activate();
    }
    public void stopAnimate(){

    	gl3dcomponent.deactivate();
    }
}

Fix the sequential displaying