I have a problem. in which I need to run a list of running objects with some delay in each query execution.
Say for example, I have a list below
List<MyReqObject> myReqObjects=new ArrayList<MyReqObject>();
and I created an artist with X number of threads as shown below
ExecutorService execute=Executors.newFixedThreadPool(X)
now with the help execute.invokeAl(myReqObjects);i am trying to call all these queries ...
but I have to have a delay between them. for this i tried
ScheduledExecutorService scheduler =Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(myObject, 2, 7, SECONDS);
but here I can not send the list as an argument so that I can execute the same request within 7 seconds with a delay of 2 seconds ...
so there is a way to solve my problem please suggest me
source
share