jak zawiesić wątek za pomocą identyfikatora wątku?
Kod, który próbuję
public void killJob(String thread_id)throws RemoteException{
Thread t1 = new Thread(a);
t1.suspend();
}
Jak możemy zawiesić / wstrzymać wątek na podstawie jego identyfikatora? Thread.suspend jest przestarzały, Aby to osiągnąć, musi istnieć jakaś alternatywa. Mam identyfikator wątku, który chcę zawiesić i zabić wątek.
Edytuj: użyłem tego.
AcQueryExecutor a=new AcQueryExecutor(thread_id_id);
Thread t1 = new Thread(a);
t1.interrupt();
while (t1.isInterrupted()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
t1.interrupt();
return;
}
}
Ale nie jestem w stanie zatrzymać tego wątku.