Solved

Destroy Thread !!!

Posted on 2001-09-03
9
824 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Modeling a class in java 5 46
reasons why a "inside Menu" would not appear for a web server 6 56
PDFBox - convert image to PDF, PDF resolution 3 115
Unable to start eclipse ? 17 128
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now