I have a pool of threads which are working independently. Basically these threads are getting data from websites. I have also another thread which change my System IP. I just need to pause all other threads while another thread is changing ip. As soon as ip will change then other threads pool will resume.
Is there any solution?
Here is my Code:
for(;;){
for (int aa = 0; aa < pages.size(); aa++) {
if (pageID != null) {
t = new Thread(new BackgroundThread(pageID.get(aa)));
System.out.println(pageID.get(aa));
t.start();
}
if(ipNo == 3){
ipNo = 0;
}
if(aa == 35) {
//Following method take a little bit time to change ip. I need when this method will be executin then
//all above threads "t" will be paused
IPRotator.rotateIP(ip[ipNo]);
//When IP will be change then all paused threads will be resumed
ipNo++;
}
}
}