?
Solved

Destroy Thread !!!

Posted on 2001-09-03
9
Medium Priority
?
869 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 600 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

801 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