Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Shutdown Hook Exception while removing reference

807603Dec 16 2007 — edited Dec 16 2007
Am getting the below exception thrown multiple times after my shutdown hook has completed. The class Settings is entirely static and the hook is to ensure it's save() method is called on program exit, usually via the gui close button. The save is very short and does complete. When debugging the exception is only raised after the run method completes and the threads exit method terminates.
Is this the best method to ensure save is called and if so what is going wrong?
Thanks

Exception while removing reference: java.util.concurrent.RejectedExecutionException
java.util.concurrent.RejectedExecutionException
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1759)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92)
at sun.awt.shell.Win32ShellFolder2$ComTask.execute(Win32ShellFolder2.java:1214)
at sun.awt.shell.Win32ShellFolder2$FolderDisposer.dispose(Win32ShellFolder2.java:170)
at sun.java2d.Disposer.run(Disposer.java:128)
at java.lang.Thread.run(Thread.java:619)
// ensure save on exit
Runtime.getRuntime().addShutdownHook(new Thread("SettingsSaver") {
	public void run() {
		try {
			Settings.save();
		} catch (SettingsException e) {
			JOptionPane.showMessageDialog(null, e.getMessage(),
					"Error Saving Settings",
					JOptionPane.WARNING_MESSAGE);
		}
	}
});
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 13 2008
Added on Dec 16 2007
1 comment
1,340 views