//start threads
for (int i=0;i<arrForagers.size();i++)
{
arrForagers.get(i).start();
}
//create join action for all the threads ************this is the problem*****************
for (int i=0;i<arrForagers.size();i++)
{
try {
arrForagers.get(i).join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
//from this point all the threads have completed successfully.
|