Java Thread Interrupted() Method Explained
This method returns a boolean value indicating whether the current thread has been interrupted or not.
The method first gets a reference to the current thread by calling the static method 'currentThread()' of the 'Thread' class. Then it calls the 'isInterrupted(boolean)' method of the 'Thread' class on the current thread passing 'true' as an argument.
The 'isInterrupted(boolean)' method checks if the thread has been interrupted and clears the interrupted status if the boolean argument is 'true'. By passing 'true' as an argument, we ensure that the interrupted status is cleared after checking, so that subsequent calls to this method return 'false' until the thread is interrupted again.
Therefore, if the current thread has been interrupted, this method will return 'true', otherwise it will return 'false'.
原文地址: https://www.cveoy.top/t/topic/nIL3 著作权归作者所有。请勿转载和采集!