What is the use of interrupt() function of Thread class?
if we call this function on a thread, then it will be killed immediately.
we call this function on a thread, to request it to stop what it is doing currently.
if we call this function, then the calling thread will be suspended indefinitely.
this function is used by OS to wake up a Thread which is in Sleep mode.
Assume that we are having two threads thread-A, and thread-B. CPU is executing both the threads by time slicing technique. In this case if thread-A want's to get the complete time of CPU, then it can request thread-B to halt for some time by calling interrupt() method on thread-B's object.
Back To Top