I have a program with 2 java processes: processA and processB (2 process java.exe not 2 threads). I use the code block below from process A to call processB, this code is wrapped in the RunTask class below
public class RunTask implements Callable<Object> { private String runParams; public String getRunParams() { return runParams; } public void setRunParams(String runParams) { this.runParams = runParams; } @Override public Object call() throws Exception { try {
and the main class I use a performer
ExecutorService eservice = Executors.newSingleThreadExecutor(); while (1 == 1) { String stringParams = getFilesNeedToImportAsString(); if (stringParams.trim().isEmpty()) { long l1 = System.currentTimeMillis() - l; System.out.println("all time" + l1 / 1000); System.exit(100); } RunTask runTask = new RunTask(); runTask.setRunParams(SystemInfo.RUN_COMMAND + stringParams); Future<Object> objectFuture = eservice.submit(runTask); while (!objectFuture.isDone()) { System.out.println("waiting the task running"); Thread.sleep(500); } }
But when an exception occurred in processB, both processes (processA, processB) seem to be stopped, this is the code executed on processB
public Object call() { try { MutationResult result = mutator.execute(); return "ok"; } catch (Exception exp) { exp.printStackTrace(); System.out.println("error on " + Thread.currentThread().getName() + "failed begin retry " + (++retryCount)); call(); System.out.println(retryCount + " completed"); return "ok"; } }
If I run processB separately (on the command line), it will never happen, or when this problem occurs, I use taskmanager to kill proceesA (calllee), processB continues to work
Please give me a solution to this problem!
source share