What happened to interrupted thread?Will it give up CPU cycles.?
Interrupted thread will be put in the ready-to-run state.
Being interrupt() called from a sleeping state it doesn't
use so much CPU cycles.
Then, what is interrupted status of thread.?
Interrupted is not a state but an operation made on a thread
to wake up a thread from sleeping state.
Last one, why interrupted() static function chenges status ?
This is what jdk documentation says
about public static boolean interrupted()
"Tests whether the current thread has been interrupted.
The interrupted status of the thread is cleared by this method.
In other words, if this method were to be 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)."
and about public boolean isInterrupted()
"Tests whether this thread has been interrupted.
The interrupted status of the thread is unaffected by this method.
Returns:true if this thread has been interrupted; false otherwise."
and about public void interrupt()
"Interrupts this thread.
First the checkAccess method of this thread is called with no arguments.
This may result in throwing a SecurityException.
Throws:SecurityException - if the current thread cannot modify this thread."
Next have a look at what interrupt() does Hope that helps.