how to stop thread permanatly after start?

hello,

i am using one thread . that thread start with time delay 10 seconds as follow,

class tableUpdateThreadimplements Runnable

{

Thread thread;

int i,j;

tableUpdateThread()

{

thread =new Thread (this,"Table updation");

thread.start();

}

publicvoid run()

{

System.out.println (" Update thread starts........");

}

try

{

System.out.println (" Update thread starts 4........");

Thread.sleep(10000);

}catch(InterruptedException ee)

{

System.out.println ("");

}

}

but, in one point in program, i stopped the thread by,

tableUpdateThread.thread.stop();

but, the thread again started after 10 seconds.

Whhen I go to another panel, I need to stop the thread permanatly.

But, in panel 1 I need the thread update the JTable every 10 seconds.

but in panel 2 I need to stop the thread completely.

how can I do it.

please help me.

[1650 byte] By [rameshsa] at [2007-11-27 7:48:34]
# 1

Thread.stop has been depracated as unsafe.

The legitimate way for a thread to stop is for it to return from the run() method.

Typically you do this by interrupting the thread. If the thread is in sleep or wait this will trigger an InterruptedException. If not, it sets a flag, which the thread should check when it does a loop.

(If a thread calls sleep or wait after being interrupted, it throws InterruptedException immediately.)

malcolmmca at 2007-7-12 19:29:26 > top of Java-index,Java Essentials,Java Programming...