मैं एक धागा बाधित करने के लिए चाहते हैं, लेकिन बाधा आह्वान() काम नहीं लगता है, नीचे दिए गए नमूना कोड है:क्यों बाधा() अपेक्षा के अनुरूप काम नहीं और यह कैसे काम करता
public class BasicThreadrRunner {
public static void main(String[] args) {
Thread t1 = new Thread(new Basic(), "thread1");
t1.start();
Thread t3 = new Thread(new Basic(), "thread3");
Thread t4 = new Thread(new Basic(), "thread4");
t3.start();
t1.interrupt();
t4.start();
}
}
class Basic implements Runnable{
public void run(){
while(true) {
System.out.println(Thread.currentThread().getName());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
System.err.println("thread: " + Thread.currentThread().getName());
//e.printStackTrace();
}
}
}
}
लेकिन उत्पादन की तरह दिखता है thead1 अभी भी चल रहा है। तो क्या कोई इसे समझा सकता है, कैसे इंटरप्ट() काम करता है, धन्यवाद
: आपकी मदद – jason