Basically, I have several threads each completing tasks.
Although I have multithreaded the tasks within this subroutine to speed up overall program speed.
I need this subroutine to only close when all threads within it are finished, as after this subroutine is complete the information generated is required by the next subroutine to run in the program.
In contrast to what happens now, which is allowing the subroutine to close and leaving contained threads to run in their own time, in the background. Which forces the next subroutine to run, to only act on partial data.
How do I do this?
Code:
public void MainSetupTasks() throws ClientProtocolException, IOException {
new Thread(new Runnable() {
@Override
public void run() {
// Tasks to be complete
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// Tasks to be complete
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// Tasks to be complete
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// Tasks to be complete
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// Tasks to be complete
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// Tasks to be complete
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// Tasks to be complete
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// Tasks to be complete
}
}).start();
}