We write a java agent, which among other things provides some sort of GUI using java.awt.TrayIcon . When we use this agent in, e.g. Tomcat, we have the following problem:
- User starts Tomcat using shell script
- Our agent adds icon to systray
- User shuts Tomcat down using shell script
- AWT Event thread sees, that there is still displayable component, systray icon, and does not quit
- As AWT Event thread is non-daemon thread, whole application cannot quit
Now the question is, what should we do, to allow an application to shut down? Is it possible to make AWT Event dispatch thread daemon? Is there shutdown hooks for agents? Anything else?