Solved

Destroy Thread !!!

Posted on 2001-09-03
9
858 Views
Last Modified: 2008-01-09
I'm running a program from within java using

  p = Runtime.getRuntime().exec(cmd, null, cwd);

I want to kill(close) this program. I tried to destroy the process. tried to make a class that extends Thread and ran that command from its run() & tried to destroy this thread. but Thread.destroy() is NOT IMPLEMENTED as Java doc says !!!!!!!!!!!!!!.

   so, i tried to interrupt this thread but nothing happens also.

  I searched JDC at sun but got nothing. CAN ANY ONE HELP ME PLZ?!!!!!!!
thanks
0
Comment
Question by:mhussein
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 6450863
you start new PROCESS (which is native OS Process), not Thread.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6450864
processes may be quite tricky

have you tried process.destroy() ?
what OS/JDK are you using ?
0
 
LVL 2

Expert Comment

by:vasan_sr
ID: 6450883
Just check the Thread isAlive....and then try to destroy the thread...
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:mhussein
ID: 6450919
I'm using JDK 1.3.1 on Solaris 5

I tried process.destroy() but nothing happened, that is what made try the thread thing.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6451011
1. did you read this bug report
http://developer.java.sun.com/developer/bugParade/bugs/4073195.html

2. the only thing that I can suggest is to start some other native process that is going to kill the first one (using kill() or whatever)
0
 

Author Comment

by:mhussein
ID: 6451028
How can i get the pid of the first one?

Another big problem is that i tried to kill it manually from the cmd line, but it had childs and oh they went zombie !!!.

I've seen the bug report, That is exactly my problem. How can i solve it? do u have any clues heyhey_?

I've heard u r going to leave!!!! :-(. plz don't.

Thanks for ur help heyhey_.
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 150 total points
ID: 6451034
try making two shell scripts
first one will start your process / save pid, etc.
second one will kill that process, childs etc.

if you can create such scripts, you'll probably be able to start them from Java ...

re leaving - well, I'm back at the moment :)
0
 
LVL 5

Expert Comment

by:vemul
ID: 7766054
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- points to heyhey_

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7847350
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question