|
Re: How to stop a Thread?
|
Posted: Jun 23, 2003 2:32 PM
|
|
If I understand your question correctly then 1. You are in main() method of the class you are running 2. You are getting the current thread 3. You are invoking sleep method on current thread 4. After sometime or after some condition is met you want to stop the thread
The currentThread() method inside the main method is giving you the main thread that was started to run your program. If you stop that thread then it is tantamount to stopping the program. If you want to stop the program itself, you can achieve it by calling System.exit() method based on your condition. If you wanted to do something else, please ignore my message.
|
|