Is there a clean way to get AWT event dispatch thread

I am trying to do some AWT Event Dispatch Thread (EDT) status monitoring from a separate thread. If I start to skip heart beat, I want to reset the trace of the EDT stack. The problem is that EventQueue does not provide a way to get the current dispatch stream, the method that does is a private package (probably for good reason). Therefore, I can either search all the threads, or search for a stream with a name like AWT-EventQueue-X or use invokeLater or invokeAndWait and have the current save from the stream, something like:

EventQueue.invokeLater(new Runnable() { public void run() { eventDispatchThread = Thread.currentThread(); } }); 

Then, every time I go to drop the thread stack, I must first make sure that the EDT that I have is still alive, and if I don’t go through the whole process again, to get the thread. I'm just looking for a cleaner way to do this.

+6
java swing awt
source share
1 answer

Alternatively, you can extend the EventQueue as shown here .

+1
source share

All Articles