-
Killing Thread in java
Everyone says how to kill thread voluntary . But I want to know how to kill thread from other application.
I have thread with run method is something like follows.
Class MyThread extends Thread{
Public void run(){
Calling method
> this method may take several hours to finish his execution
}
}
Please suggest me a solution to kill an object of this thread before it finished it execution.
This method call one time and this wont useful for me
Public void run(){
While(condition){
Calling Method
}
}
-
if thread is not cooperating,
there is only one way: use Thread's stop() method (which is deprecated.)
http://java.sun.com/j2se/1.5.0/docs/...precation.html
as i understood, unsafety arises:
- when you use same object inside some threads,
and one thread stop ungracefully (it unlocks monitors),
so other threads are allowed to use object,
other threads may encounter incomplete state of this object.
at least one of these conditions meet, to use stop() should be safe (?i am waiting comments):
- stopped thread do not share any object with other threads.
- all shared objects (stopped thread uses) dont hold state.
- all shared objects (stopped thread uses) are immutable.
i hope it helps, as a start point to search more.
Similar Threads
-
Replies: 9
Last Post: 09-19-2007, 05:58 AM
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
By Kevin Chien in forum Java
Replies: 3
Last Post: 09-12-2000, 05:17 PM
-
By JJ in forum Enterprise
Replies: 1
Last Post: 07-06-2000, 04:50 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks