Solved

Destroy Thread !!!

Posted on 2001-09-03
9
814 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_
Comment Utility
you start new PROCESS (which is native OS Process), not Thread.
0
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
processes may be quite tricky

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

Expert Comment

by:vasan_sr
Comment Utility
Just check the Thread isAlive....and then try to destroy the thread...
0
 

Author Comment

by:mhussein
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…

744 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

18 Experts available now in Live!

Get 1:1 Help Now