title: How to report AWT/Swing event queue length programmatically?
body: <p>Ideally, the answer will be platform independent, but platform specific, particularly Oracle JVMs, are useful as well. The project that I'm working on is still running a version 6 JVM.</p>
  
  <p>The particular need has to do with a GUI that is "freezing" from time to time. I'm well aware of doing on GUI work on the EDT. The program was working well on Windows, but after moving to Linux, these "strange" GUI issues began to happen. Actually, this issue has occurred on two applications, both after a Windows to Linux move. JVisualVM shows over 10 million <code>java.awt.EventQueueItem</code> objects. The suspicion is that the AWT queue is growing faster than it's being served on Linux, so the idea is to put an AWT queue length indicator on the app and see what it shows as the queue grows/shrinks.</p>
  
  <p>A bit of Googling found <a href="https://www.java.net//node/694232" rel="noreferrer">this</a>, but it does a linear scan of the queue. Maybe there's some better way?</p>