1.JFrame调用2. JFrame - wait()=>两个都被阻止了?
我遇到了一个问题:我有一个jframe1调用了ActionPerformed jframe2。
JFrame是线程还是?所以我在jframe2中尝试了wait()方法,然后我会在jframe1中通知jframe2 ..
我在jframe2中的代码(单击按钮时运行的方法):
private void read(){
synchronized(jframe1){
try {
if(writer.checkLast() == null){
this.wait();
jLabel.setText(writer.getLast());
}
else{
jLabel.setText(writer.getLast());
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
但问题是,如果我使用this.wait();在jframe2中,我的jframe1也被锁定..我做错了什么?
我的英语不好,谢谢,如果有人有答案的话!
没有找到相关结果
已邀请:
2 个回复
细屠截殴些
贡炮逗握惫