This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to kill a user thread forcefully?

 
Mohit Jain
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers

Please tell how do we kill a user thread as no such method is provided by th 'Thread' class.
 
Manfred Klug
Ranch Hand
Posts: 377
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mohit,

There is such a function. But you should read the API Documentation carefully why you shouldn't use it.
 
Mohit Jain
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manfred

I know we can use depricated method 'stop()' to stop the thread.

But if I dont want to use any depricated method then how to kill a running thread??

Thanks in advance..
 
Manfred Klug
Ranch Hand
Posts: 377
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mohit Jain:
I know we can use depricated method 'stop()' to stop the thread.

But if I dont want to use any depricated method then how to kill a running thread??

Then the answer is: There is no such function. And if you understand the API documentation you will know why.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The basic method for stopping a thread is outlined here.
 
Henry Wong
author
Marshal
Pie
Posts: 20835
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mohit Jain:

I know we can use depricated method 'stop()' to stop the thread.

But if I dont want to use any depricated method then how to kill a running thread??


There is a reason why stop() is deprecated. It is deprecated because when you force a thread to stop, instead of asking it to stop gracefully, you can leave variables in an indeterminate state -- as locks are forced to be released.

stop() is deprecated because there is no guaranteed safe way to force a thread to stop.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic