In java, stop() method kills/terminates the currently executing thread.
class A extends Thread {
public void run() {
for (int i = 1; i <= 5; i++) {
if (i == 3)
stop();
System.out.println("A" + i);
}
System.out.println("Exit from A");
}
}
public class TestMain {
public static void main(String args[]) {
A a = new A();
a.start();
}
}
Result
A1 A2
Description: in the above program, when