Re: Java Thread

Discussion in 'Java' started by Manish Jethani, Jul 23, 2003.

  1. 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
    Manish Jethani, Jul 23, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman

    Terminating a thread from the main thread

    Charles A. Lackman, Dec 9, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,532
    Herfried K. Wagner [MVP]
    Dec 9, 2004
  2. pawo
    Replies:
    0
    Views:
    473
  3. Stephen Miller
    Replies:
    3
    Views:
    3,950
    Stephen Miller
    Jul 2, 2004
  4. Johanna
    Replies:
    0
    Views:
    595
    Johanna
    Oct 13, 2004
  5. =?Utf-8?B?Sm9oYW5uYQ==?=
    Replies:
    3
    Views:
    1,943
    =?Utf-8?B?Sm9oYW5uYQ==?=
    Oct 15, 2004
Loading...

Share This Page