I'm executing a batch file using java command and reading batch data in text file putting in database. For example I have to run for 430 nodes within 15 min interval using same batch file. So I divided 430 node in 12 threads, so each thread contains 40 nodes pointing same batch file . But threads running parallel are not able wait for the batch file command to complete. I can't make wait for each thread, because all task should complete within 15 min. Any suggestions?

Below is piece of code running multi-threading. 

```
 for (int i = 0; i < noOfMainThreads; i++) {
        // running 12 thread for 40 node 
        threadArr[i] = new Thread(runnableArr[i]);
        runnableArr[i] = new CodeBatchfile(nodeArr,nodeidArr);
    }

    for (int i = 0; i < noOfMainThreads; i++) {
        threadArr[i].start;
    } 

 class CodeBatchfile{  

    void run(){
        for (int i=1;i<nodename.length;i++) {
            // exciting batch file using 12 threads.
            cmd = filepath + " " + nodenamelocal;
            try {
                process = Runtime.getRuntime().exec(cmd, null, bdir);
                process.waitFor();
            }
            catch(Exception ex) {
                System.out.println("Exception Running batch file" + ex.getLocalizedMessage());
            }
        }
    }

```