Reputation: 959
For concurrency handling i have written and executor class :
ExecutorService service = Executors.newFixedThreadPool(10);
Future<List<Content>> submit = service.submit(new PushClass(pushlist, content));
List<Content> resu = submit.get();
and Below is the push class that implements the Callable interface :
public class PushClass implements Callable<List<Content>> {
List<Content> ls;
String content;
public PushClass(List<Content> ls, String content) {
this.ls = ls;
this.content = content;
}
private synchronized String push(String msisdn, String content, String Cli) {
// hitting the push url
} catch (Exception e) {
e.printStackTrace();
}
return status;
}
@Override
public List<Content> call() throws Exception {
for (Content c : ls) {
c.setResponse(push(c.getMsisdn(), content, c.getCli()));
}
return ls;
}
Upto what limit can i increase the thread to as to prevent any queuing in the server or can i make the pool dynamic ? Sometimes tomcat is showing error as , "The Other thread are in process" , can i dynamically scale it.
Upvotes: 2
Views: 132
Reputation: 3017
Upvotes: 3