Could you explain what java.lang.Thread.interrupt() does when invoked?
java.lang.Thread.interrupt()
Thread.interrupt() sets the interrupted status/flag of the target thread to true which when checked using Thread.interrupted() can help in stopping the endless thread. Refer http://www.yegor256.com/2015/10/20/interrupted-exception.html
Thread.interrupt()
Thread.interrupted()