I think I should deal with something like thread pool. I am familiar with java thread api such as ThreadPoolExecutor, Future, CompletionService. but is there any equivalence library in CMS?
On Fri, Mar 7, 2014 at 10:40 AM, Li Li <fancye...@gmail.com> wrote: > hi all, > I want to wrapper a high level library using activemq to > implement a request-reply service. the user of this library have 2 > kind of api --synchronized blocking and asynchronized callback. > usage1: > MainThread: > RequestResponseWrapper wrapper=new RequestResponseWrapper(); > wrapper.setMaxConcurrentThrad(10); > wrapper.setTimeout(10000); > Thread[] workers=new Thread[N]; > for(int i=0;i<N;i++){ > workers[i]=new WorkerThread(wrapper); > workers[i].start(); > } > for(int i=0;i<N;i++){ > workers[i].join(); > } > WorkerThread: > while(true){ > String req=...; > String response=wrapper.request(req); > System.out.println(response); > } > usage2: > MainThread: > RequestResponseWrapper wrapper=new RequestResponseWrapper(); > wrapper.setMaxConcurrentThrad(10); > wrapper.setTimeout(10000); > CallBack callBack=new CallBack(); > wrapper.setCallBack(callBack); > while(true){ > String req=...; > wrapper.asyncRequest(req); > } > CallBack: > onSuccess(String request,String response){ > > } > onFail(String request, int failReason){ > > } > > > Any suggestion for me? I need implement both the java and c++ library.