I have two threads and I want the second thread to wait until first thread finishes. How can I accomplish this?
This my code:
public class NewClass1 implements Runnable {
// in main
CallMatlab c = new CallMatlab();
CUI m = new CUI();
Thread t1 = new Thread(c);
t1.start();
Thread t2 = new Thread(m);
try {
t1.join();
} catch (InterruptedException ex) {
Logger.getLogger(NewClass1.class.getName()).log(Level.SEVERE, null, ex);
}
t2.start();
//
public void run() {
throw new UnsupportedOperationException("Not su..");
}
}