IsAlive tests whether the thread is active. The so-called activity State, refers to the thread has been started and has not been terminated.
Sleep means that execution is paused, but the thread is still alive, that is, isalive or true.
GetID gets the thread unique identity.
stopping a thread is more important than the beginning and end.
This explains, stop the thread, can not use stop, this method is deprecated, like suspend and resume, are obsolete methods, using them may produce unpredictable results.
The current methods of stopping threads are:
1. Using the exit flag, the thread terminates after the Run method completes. It is recommended to use the method of replanting.
2, use stop, not recommended, should not be used.
3, use interrupt. This method does not stop immediately, but is a similar flag in the thread.
To determine if a thread is in a stopped state:
1, Interrupted (), indicates whether the current thread is interrupted. If true, indicates an interrupt, it will break the flag 0 (that is, set to false)
2, isinterrupted (), indicates whether the thread is interrupted. Returns true to indicate an interrupt and does not empty the interrupt flag.
The difference between the two is that either object invocation, or x.interrupted (), indicates whether the thread that called the method statement was interrupted. The latter x.isinterrupted () indicates whether the X object has been interrupted.
This article is from the "Happy Cup of Tea" blog, please be sure to keep this source http://gugw9handsome.blog.51cto.com/1187812/1784161
Some methods of Java threading Learning-thread