Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to stop a thread without using stop()

Reply
Thread Tools

How to stop a thread without using stop()

 
 
Christophe Vanfleteren
Guest
Posts: n/a
 
      04-09-2004
J. David Boyd wrote:

>>
>> That might be kind of hard to do, considering that Thread does not
>> have a kill() method.
>> It does have a destroy() method, but that has never been implemented.
>>

>
>
> Even if it did, what about lost resources or indeterminate state? Isn't
> that the reason that stop() was deprecated in the first place?
>
> Dave


Exactly.

There's more info on this here:
http://java.sun.com/j2se/1.4.2/docs/...precation.html

--
Kind regards,
Christophe Vanfleteren
 
Reply With Quote
 
 
 
 
mr_organic
Guest
Posts: n/a
 
      04-09-2004
>> If you keep a reference to the thread id (a numeric, I think), you
>> should be able to kill() that thread, yes? So you put a timer or a
>> semaphore on the thread, and if it doesn't complete within the given
>> parameters, you issue a kill().
>>
>> mr_organic

>
> That might be kind of hard to do, considering that Thread does not
> have a kill() method.
> It does have a destroy() method, but that has never been implemented.
>


Ah, I meant destroy() rather than kill(). I didn't know that it was
unimplemented, though. Why put the API in there and then tell people not
to use it? Same goes for stop(), etc. Seems like a pretty crappy thread
API design to me if that's the case -- it sounds like the designers of
the threading API were counting on underlying POSIX semantics (a la
Solaris) everywhere, but found that these semantics didn't translate well
to WIN32 threads (or other non-POSIX threading models, for that matter).

*shrug*

One of the reasons I liked the C-based select() method better than
threads (Java-based or otherwise) was because it avoided all the hellish
problems of threads -- races, deadlocks, all the rest -- and still gave
you most of the concurrency benefits (albeit not with multi-CPU ability).
I think programmers are too quick to use threads when other concurrency
methods would work just as well, and far more simply.

FWIW.

mr_organic
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Try to stop thread Using flag many_years_after Python 2 11-25-2006 05:01 PM
Thread.stop makes thread unabled to be signalled Benji Java 34 10-28-2005 09:02 AM
How to allocate mem without using malloc() & free without using free() Rajshekhar C Programming 5 03-29-2005 06:03 PM
How to stop java service with command line parameter '-stop'? Will Java 1 11-02-2004 03:32 PM
Stop Debugging doesn't stop in ASP.NET Matt Theule ASP .Net 7 07-24-2003 07:38 PM



Advertisments