NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Thread.sleep in loop warning

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers
View previous topic :: View next topic  
Author Message
Stefano Gargiulo
Posted via mailing list.





PostPosted: Wed Jul 07, 2010 12:25 pm    Post subject: Thread.sleep in loop warning Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo