您好我有一个问题,恢复线程我的代码是错误后进入睡眠
public boolean Wait(String Reply){
if (Reply.equalsIgnoreCase("Y")){
try {
t.resume();
}
catch (Exception e){
System.out.println("\n" + "The exception in resume thread method:::: " + e);
}
System.out.println("\n" + "In the Wait Function of Sender");
return true;
}
JOptionPane.showMessageDialog(j ,
"Please Wait While The User Accpets the Trasmission ",
"",
JOptionPane.INFORMATION_MESSAGE);
try{
t = new Thread(this);
t.sleep(100000);
}
catch (InterruptedException ie){
System.out.println(ie.getMessage());
}
return false;
}
我可以解释你是怎么回事,因为这将帮助ü确定问题。 首先线程进入睡眠......然后我从另一个函数ReplyYes
调用这个函数public boolean Wait()
它传递值“Y”,然后我尝试恢复线程,但调用t.resume()
函数,而不是恢复线程给我一个Java.Lang.Null.PointerException
和线程不会恢复导致返回一个FALSE值。另外因为这个线程我甚至不能停止我的服务,我不得不等待线程超时。
任何人都可以解释如何使其正常工作! 谢谢