• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Event Dispatcher Thread frozen

 
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good morning,

I'm encountering a strange problem in a swing gui JDialog .
Randomly, with no dependency on data displayed, displayed dialog seems to be frozen, i.e user cannot type anything in JInputBoxes, nor use JComboBoxes and so on... quite strangely, user is able to press some Jbuttons which actually execute "event code" (like closing the dialog)
Googling for a while, I found several posts where an Event Dispatcher Thread frozen issue is discussed. I don't know if that's may be my case, anyway i'd like to know if someone may help me suggesting any workarounds: is there a mean to "restart" EDT ?

Thanks in advance,
Regards.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check carefully that your code respects Swing's single threaded rule and that all Swing constructors and methods are invoked on the EDT. Also verify that no long-running task, like network or database access, is executed on and possibly holding up the EDT. Such tasks should be performed in a background Thread, commonly by using a SwingWorker. See Concurrency in Swing for more details.

Note that some methods documented up to Java 6 as thread safe, are actually not. The documentation has been corrected in Java 7.

If the problem persists and can be whittled down to a SSCCE (<- link) post that here and someone will try to get to the root cause.
 
Claude Moore
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Darryl, of course I'll investigate further and deeper about Concurrency in Swing as you suggested. Anyway, just in case in which EDT is frozen, is there any way to "reset" it ?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, there's no way to "reset" it. Instead of trying to fight symptoms, you should find the cause of the problem, and fix that.

The EDT doesn't freeze randomly. There must be something in your program that causes this - some long-running task that's running on the EDT. For example, don't run tasks that might take a long time, such as database queries, directly from the event handler of a button press, because the event handler runs on the EDT and if you perform a long-running task there, your GUI will not respond.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the EDT freeze at all? Maybe only if something deadlocks, as Jesper has already implied.
 
Claude Moore
Bartender
Posts: 1357
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right. I don't mean a complete freeze, maybe only a deadlock.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic