I have a method with two threads (1 &2) which run at the same time. The current thread must stop right after the ‘thread2.start()’ statement until thread2 & thread1 are finished. There appears to be multiple approaches to do this but I find them confusing. Can anybody point to me a simple approach to accomplish this? Join does not appear to work since thread 1 & 2 must run at the same time. Thanks in advance
Runnable storm = new Storm();
Runnable UpdatePB = new UpdatePB();
//these two threads must run at the same time
thread1 = new Thread(storm);
thread2 = new Thread(UpdatePB);
thread1.start();
thread2.start();
//code must stop here until thread2 is finished