Elliott
Elliott

Reputation: 5609

Closing a JOptionPane Causes a Deadlock in Java Swing

I have an application which runs OK at most sites. But one site, which is hosting the application on a Citrix Box appears to have a deadlock problem. I ran a profiler on the session and received a surprise. The statement causing the deadlock appears to be a statement which closes a JOptionPane dialogue box. Please see the enclosed display.

So I have three questions:

  1. Is my interpretation correct?
  2. Any idea of why this can happen.
  3. What can I do in code to prevent this from occurring?

Thank you in advance for your help.

ElliottProfiler display

Upvotes: 3

Views: 500

Answers (2)

Grodriguez
Grodriguez

Reputation: 21995

Swing is not thread-safe. Perhaps your app is calling Swing GUI methods from outside of the Event Dispatch Thread.

If you can reduce this to a minimal sample that still reproduces the problem, you will either 1) find the cause yourself in the process, or otherwise 2) end up with a much greater chance of getting help from someone else.

Upvotes: 5

Andrew Thompson
Andrew Thompson

Reputation: 168825

  1. Don't know, but if it is..
  2. Calling GUI methods (update the GUI) off the EDT.
  3. Call GUI methods on the EDT.

Upvotes: 4

Related Questions