Deadlock with gvtRenderingCompleted without Swing threads

kototama kototama <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <[email protected]>
Hello,

I would like to block and wait until the rendering of the SVG DOM is
completed. What is wrong with the following code? It blocks even if no
Swing thread is involved.

Thanks in advance for your help.

public class DeadLock {

	private static final String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final Object mutext = new Object();

		DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
		Document doc = impl.createDocument(svgNS, "svg", null);

		JSVGCanvas canvas = new JSVGCanvas();
		canvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
			@Override
			public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
				System.out.println("completed");
				synchronized (mutext) {
					mutext.notifyAll();
				}

			}
		});

		synchronized (mutext) {
			System.out.println("Loading document");
			canvas.setDocument(doc);
			System.out.println("Waiting for document to be loaded...");
			try {
				mutext.wait();
				System.out.println("rendering finished");
			} catch (InterruptedException ie) {
				ie.printStackTrace();
			}
		}
	}

}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.