Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: Java Thread

Reply
Thread Tools

Re: Java Thread

 
 
Manish Jethani
Guest
Posts: n/a
 
      07-23-2003
pablo wrote:

> I have a big thread problem in Java. I need to kill a thread that is
> the issue. But when I try to kill a thread (with a jni API to C) the
> JVM doesn't deregister this thread. Somebody can help me please.


What are you doing here?!! Let me guess... you're making a JNI
call to actually kill a Java thread, using the kill syscall on
Linux! (Bingo?)

What is your motivation?

> The only thing I need is kill a thread, but when I want not with a
> clean stop procedure, like Sun recomend against thread.stop() method.


Let the thread die of its own. If you want to do something close
to killing a thread, have the run method make a check like this:

public void run()
{
for (; {
if (Thread.interrupted())
break;

[...]
}
}

From outside of this thread, you just call Thread.interrupt()
on it. Also, if you're calling sleep() on the thread, then you
should catch InterruptedException and break from there.

-Manish

--
Manish Jethani (manish.j at gmx.net)
phone (work) +91-80-51073488

 
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
Combining Java Reflection API with Java Annotation Types for Thread Safety pek Java 2 10-23-2007 03:00 PM
Terminating a thread from the main thread Charles A. Lackman ASP .Net 3 12-09-2004 02:12 PM
"Thread was being aborted" error from WebApp using Thread.Sleep. Stephen Miller ASP .Net 3 07-01-2004 11:50 PM
perl 5.8.2/3 - thread started by a thread pawo Perl 0 02-16-2004 01:18 PM
java Bug? -> Java threads: Wait X Notify X [Thread AGAINST Runnable] Renato Battaglia Java 3 10-24-2003 04:54 PM



Advertisments