1

To start with it is a huge application and the problem concerns many lines so I can't really attach any code.

After a change that consists mainly of clearing and re-adding elements to some collection, swing GUI of the application freezes. That freeze doesn't happen while that added code is executed but some time afterwards. What makes it strange is that no thread is suspended.

My question is whether the infinite loop is the only explanation of this problem. It feels unlikely to me that this is the case because the added code finishes without problems. There may be some unsynchronized collection access issue, but I don't see it leading to that situation. It doesn't look also like we are dealing with a deadlock coming from synchronization problem since no thread is suspended.

Atom
  • 616
  • 1
  • 5
  • 14
  • Have you tried using a debugger? If the GUI freezes, you should see something in the Event Dispatching Thread (in Eclipse you can pause any Thread on the fly and see where it is currently). Another option, is to use JConsole and look at the Threads and their current stack call. – Guillaume Polet Dec 04 '12 at 11:01
  • GUI freeze ... take a thread dump and see what is blocking the AWT thread – Robin Dec 04 '12 at 14:46
  • Those were good tips, Guillaume and Robin. Thanks. – Atom Dec 04 '12 at 20:29

4 Answers4

1

In the end it is a deadlock.

My team leader told me that threads waiting on monitor (on "synchronized") aren't shown in eclipse as suspended. He found some two threads and asked to pause them. Then I saw they are waiting for each other to release the occupied monitors.

The deadlock isn't fault of the code I entered. It's just that the change I made revealed wrong synchronization in some other place.

Thank you all for trying to help me, I really appreciate it. It is my first question on stackoverflow and I was surprised how fast had you reacted.

Atom
  • 616
  • 1
  • 5
  • 14
0

Huge application + manipulating collections -> garbage collector kicks in?

Some related reading here at SO: side effect for increasing maxpermsize and max heap size

And Oracle article about GC tuning: http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html

Community
  • 1
  • 1
hyde
  • 60,639
  • 21
  • 115
  • 176
0

It may be because of waiting (due to some heavy processing) in Event dispatcher thread in swing where events are executed. Ideally you should execute any resource intensive task in a separate thread so that UI doesn't freeze

vishal_aim
  • 7,636
  • 1
  • 20
  • 23
0

You might already know this, but just for the sake of it i would say that if you have not used a Swing worker in your long running processes within your app, this would be a ideal situation to use it.

dinukadev
  • 2,279
  • 17
  • 22
  • This GUI implementation is based on listeners and swing worker is also used. The code I added finishes instantly. – Atom Dec 04 '12 at 12:00