May 30, 2017 3:02:01 PM start
May 30, 2017 11:43:01 PM start
May 30, 2017 11:44:01 PM start
May 31, 2017 2:04:01 AM start
long startTime = System.currentTimeMillis();
long timeReserve = 20000 // milis
while ((startTime - System.currentTimeMillis())<timeReserve){
if ( isInterrupted() ) return;
if (..){}
try {Thread.Sleep(1000)}
catch (Exception e){}
}
public class ThreadsManager extends Thread {
public ThreadsManager(ArrayList<Advert> results) {
for (int i = 0; i < 120; i++) {
for (Advert adv : results) {
if (i == 119) {
adv.interrupt();
Main.log.warning(String.format("###############THREAD (advert.id=%s) WAS INTERRUPTED!", adv.id));
}
if (!adv.isAlive()) {
break;
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}