The difference between the interrupted method and the Isinterrupted method of the thread class

Source: Internet
Author: User

As shown below, interrupted () alters the interrupt state (purge) of the thread, while isinterrupted () does not affect the interrupt state of the thread

1    /*** Tests whether the current thread has been interrupted.  the
* <i>interrupted status</i>of the thread is cleared by this method. Inch
* Other words, if this method were to being called twice in succession, the
* Second call would return False (unless the current thread were
* Interrupted again, after the first call had cleared its interrupted
* Status and before the second call had examined it).
* * <p>a thread interruption ignored because A thread is not alive
* At the time of the interrupt would be reflected by this method
* Returning false.
* * @return<code>true</code> If the current thread has been interrupted;
* <code>false</code> otherwise. * @see#isInterrupted () * @revised 6.0*/

Public Static Booleaninterrupted () {2 returnCurrentThread (). isinterrupted (true);3 }4 5 6 /*** Tests Whether this thread has been interrupted. The <i>interrupted
* status</i> of the thread is unaffected by this method.
* * <p>a thread interruption ignored because A thread is not alive
* At the time of the interrupt would be reflected by this method
* Returning false. * * @return<code>true</code> If this thread has been interrupted;
* <code>false</code> otherwise. * @see#interrupted () * @revised 6.0*/

Public BooleanIsinterrupted ()
{returnIsinterrupted (false);}7 8 9 Ten /*** Tests If some Thread has been interrupted. The interrupted state
* is reset or not based on the value of clearinterrupted that is * passed. */

Private native BooleanIsinterrupted (Booleanclearinterrupted);

The difference between the interrupted method and the Isinterrupted method of the thread class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.