Solved

Destroy Thread !!!

Posted on 2001-09-03
9
842 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
oracle 11g 23 107
sql import cannot be resolved jsp 3 47
Cisco ASA: Java web start no go, asdm launcher no go 3 37
Need Help! Getting a syntax error and don't understand why 3 31
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

860 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