java.lang.IllegalStateException: Deadlock risk: AWT tree lock acquired on a showing component..

Discussion in 'Java' started by Cherukan, May 24, 2007.

  1. Cherukan

    Cherukan Guest

    Hi

    I get this error when trying to popup a Swing dialog from a long-
    running background thread.

    java.lang.IllegalStateException: Deadlock risk: AWT tree lock acquired
    on a
    showing component when not on the event dispatch thread. (NOTE: do
    *not* use
    invokeAndWait to fix this assertion failure; that will increase the
    chance of
    actual deadlock.)
    Thread name: task1-1438375310
    at
    java.awt.Component.assertThreadPolicyCompliance(Component.java:8566)
    at java.awt.Component.getTreeLock(Component.java:871)
    at java.awt.Component.getLocationOnScreen(Component.java:1651)

    I realize this is happening because the current thread is not the
    event thread.

    But the background thread must get this input from the user to
    proceed. Also the input
    depends on the processing the thread has done upto this point, so it
    cannot be
    obtained before the thread has started. After the swing dialog has
    closed, the thread
    needs to resume its processing picking up where it left off.

    As the message says, I cant use invokeAndWait.

    Whats the 'safe' approach in such a case?

    Thanks for your answers.

    Cherukan
     
    Cherukan, May 24, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page