views:

102

answers:

1

I have a Java Swing application that is being used as a cluster application. The problem is that every time the cluster tries to terminate the Java application, it just hangs and Windows displays the "End Now" dialog. The said application is a server type one so it spawns a thread for every attempt to connect to it is made.

I learned that the cluster sends the TERM signal using the program presented in this article. BUT when the console application is used as a cluster application, the cluster can just terminate the process after a few TERM signals.

I also tried the vanilla sample desktop application that's available when making a new project using NetBeans 6.8. It also won't terminate even after receiving the signal.

From the demonstrations done above, I think that it has something to do with Swing or with the threads. Can anyone help me with this? Thank you.

EDIT: It could be killed by using the task manager though I think it sends another signal.

+2  A: 

When your Java application receives the TERM signal it will run any registered shut-down hooks before terminating. One possibility is that one of these shut-down hooks is blocking indefinitely or else taking a long time (>30 seconds) to run, causing the Windows "End Now" dialog to be displayed.

One thing you could try is to register a shut-down hook that simply prints to the console and verify that it is indeed being called. However, unfortunately there'll be no way to determine whether other shut-down hooks have run at this point as hooks are run in an arbitrary order.

Adamski
I kinda "fixed" this problem by setting a force end task somewhere in the registry.I did do what you mentioned but I forgot the output. I complete forgot about this question since it was a pretty busy period.
Ramon Marco Navarro