
Hello I have worker pattern that uses ExecutorService to schedule Thread execution but getting stuck at some point when returning a value using Future.I have code snippet below:
ExecutorService threadPool = Executors.newFixedThreadPool(1);
for ( int i=1; i<4; i++ ) {
threadPool.submit(new JobImpl("Job ", i));
Now this passes job and i as job and jobNumber to JobImpl class:
public class JobImpl implements Runnable {
public String job;
public int jobNumber;
ExecutorService executorService = Executors.newSingleThreadExecutor();
public JobImpl( String job, int jobNumber ) {
this.job = job;
this.jobNumber = jobNumber;
}
public String getJob() {
return this.job;
}
executorService.execute(new JobImpl(job,jobNumber){
public void run(){
String j =Integer.toString(jobNumber);
Deque<String> jdeque = new LinkedList<String>();
jdeque.add(job+j);
}
});
Future future = executorService.submit(new JobImpl(jdeque){
public JobImpl call() throws Exception {
return jdeque;
}
});
}

I need to return the jdeque so that I can pass it on to another process but I have a problem with the submit(Callable) method.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.