Themes are synchronized
I am creating two threads, a first thread for calling the application and a second thread for the read file that results from calling the application on the first thread. Calling the application works fine, but reading the file doesn't work.
Here is my code:
/*
* 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.");
}
}
0
Mazrooei
a source
to share
1 answer
You might want to post more code because it's not really clear what you are trying to do and what your synchronization requirements are.
Which feature is your t2.wait (3). Why are you expecting three milliseconds? Perhaps you meant three seconds (3000), which is still dangerous, but might work for you?
+4
a source to share