0
첫 번째 스레드에서 두 번째 스레드를 생성하여 응용 프로그램을 호출합니다. 두 번째 스레드는 첫 번째 스레드에서 응용 프로그램을 호출 한 결과 읽기 파일로 생성됩니다. 응용 프로그램이 제대로 작동하지만 파일 읽기가 작동하지 않습니다.동기화 된 스레드
여기 내 코드입니다 :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package reciverwindow;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*
*/
public class NewClass1 implements Runnable {
public static void main(String[] args) {
CallMatlab c = new CallMatlab();
CUI m = new CUI();
Thread t1 = new Thread(c);
t1.start();
Thread t2 = new Thread(m);
t2.start();
/* try {
t2.sleep(3);
} catch (InterruptedException ex) {
Logger.getLogger(NewClass1.class.getName()).log(Level.SEVERE, null, ex);
}
}*/
synchronized (t2) {
try {
t2.wait(3);
t2.notifyAll();
} catch (InterruptedException ex) {
Logger.getLogger(NewClass1.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public void run() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
"파일을 읽지 않습니다."라고 말하면 작동하지 않는 코드를 게시하고 어떤 일이 일어나고 어떤 일이 발생하는지 예상 할 수 있습니다. –