NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Stefano Gargiulo Posted via mailing list.
|
Posted: Wed Jul 07, 2010 12:25 pm Post subject: Thread.sleep in loop warning |
|
|
Due to the new warning in 6.9 i ask you for confirmation if a loop of
this kind can have problems (i think no, i think the warning is just to
avoid typo in plain java code) :
while (!dests.isEmpty()) {
for (Thread tr : haircuttingSMTPs) {
if (!tr.isAlive()) {
haircuttingSMTPs.remove(tr);
if (dests.isEmpty()) {
break;
}
String dest = dests.remove(0);
haircuttingSMTPs.add(0, new Thread(new
DetachedMailer(message, dest)));
haircuttingSMTPs.firstElement().start();
break; //vector changed redo main while check.
}
try {
Thread.sleep(50); //sleep to give cpu to real
threads, this is just a controller
} catch (InterruptedException ex) {
Logger.getLogger(MassMailerThread.class.getName()).log(Level.SEVERE,
null, ex);
}
}
} |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|