Killing Thread in java

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Killing Thread in java

  1. #1
    Join Date
    Sep 2007

    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(){
    Calling Method………

  2. #2
    Join Date
    Sep 2005
    istanbul / Turkey
    if thread is not cooperating,
    there is only one way: use Thread's stop() method (which is deprecated.)
    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

  1. Java book
    By Lou in forum Java
    Replies: 9
    Last Post: 09-19-2007, 05:58 AM
  2. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  3. Java Thread
    By Kevin Chien in forum Java
    Replies: 3
    Last Post: 09-12-2000, 05:17 PM
  4. Re: VB vs. Visual Age for Java
    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
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center