The Artima Developer Community
Sponsored Link

Java Answers Forum
Thread stop

1 reply on 1 page. Most recent reply: Jan 2, 2003 7:44 AM by Ramzi Ben Yahia

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Danny

Posts: 8
Nickname: pok
Registered: Dec, 2002

Thread stop Posted: Jan 2, 2003 6:41 AM
Reply to this message Reply
Advertisement
Hi Everybody

I have a problem with Thread, I have created the Thread but I want to stop it, can anybody tell me how to stop it????


Many thanks.


Ramzi Ben Yahia

Posts: 23
Nickname: miccheck
Registered: Jul, 2002

Re: Thread stop Posted: Jan 2, 2003 7:44 AM
Reply to this message Reply
in the javadoc api it's recommended to use a variable to indicate that the thread should stop running
here is an example from the javasoft tutorial :


private volatile Thread blinker;

public void start() {
blinker = new Thread(this);
blinker.start();
}


public void stop() {
blinker = null;
}

public void run() {
Thread thisThread = Thread.currentThread();
while (blinker == thisThread) {
try {
thisThread.sleep(interval);
} catch (InterruptedException e){
}
repaint();
}
}

Flat View: This topic has 1 reply on 1 page
Topic: Object Streams Previous Topic   Next Topic Topic: Using RequestDispatcher

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use