tor
tor

Reputation: 85

java.lang.Process Kill not done

I am creating a SWT Application which invokes an external executable (say abc.exe) in java.lang.Process. This new process is created on 'Start' button on my composite.

The problem is that if the executbale abc.exe hangs; my entire SWT shell hangs! So I thought of adding new button called 'Stop' so the user can easily kill the hung process, but since everything executes in a single thread I am not able to press 'Stop' also.

Can anyone tell me/show me how best way I can solve this problem.

Many Thanks, Tor

Upvotes: 0

Views: 207

Answers (2)

ControlAltDel
ControlAltDel

Reputation: 35096

Process kill is in fact unimplemented in java as it is EXTREMELY DANGEROUS

Upvotes: 0

Kevin Mangold
Kevin Mangold

Reputation: 1155

You will need to run the process in a background thread. The problem is you are running both your SWT app and abc.exe in the same thread. What happens, is the processes are taking turns with request/response and there is no response from the abc.exe process so there it is sitting there waiting--the same should happen if abc.exe is executing a long-running algorithm.

Upvotes: 1

Related Questions