Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:19:47+00:00 2026-06-08T04:19:47+00:00

I am developing a web application in which I am running Java in the

  • 0

I am developing a web application in which I am running Java in the front end and shell script at the back end. The application is mainly about analysis many files and the java program gets the inputs from the user such as which file they want to analyze from which date to which date they want to analyze.Lets assume user gives data from July 1-8. I need to process the 8 days file. Each day has about 100 files to be processed. So my goal is to make this process in parallel than doing this sequential. I have basically two ideas regarding this. I wanted to share this with you ppl and get ur suggestions.

PLAN 1:
There is a Java program(Business Layer), which invokes a shell script using process builder. Can I split the given date by the user, for instance (1-8) into 4 threads where each thread would do the operation of two days. such as (1-2) thread 1 and (3-4) thread 2 and it goes on. If I follow this approach what are all the pros and cons. Also how coordinate among the threads by this approach.

Plan 2:
Call the shell script from Java and inside the shell script spawn multiple processes and as I said earlier, I can spawn process 1 to do the job of date (1-2) and process 2 (3-4) and it goes on. What are all the pros and cons of this approach. And I am writing the processed output into a single file. So if I have multiple processes how can I make the single file updated by multiple processes.

Also any reference of any links related to my question

IMPORTANT:
As I told I need to process 100’s of log files for each day inside a shell script, and one of my requirement is to constantly update my front end environment regarding the status of my jobs in shell script (i.e) day 1 has completed, day 2 has completed and so on . I know I can do echo from shell script and then I can get the value from Java. But the problem is if I do an echo inside the shell script, inside the loop of processing the files, my call terminates and I again have to call back from Java. Any ideas of how to make this update happen.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:19:49+00:00Added an answer on June 8, 2026 at 4:19 am

    First, I would suggest considering the first rule of optimization: do not optimize.

    Then if you really think you need to optimize it, I would pick the 1st approach and do as much as possible in Java.

    One approach could be the following:
    1) run all the processes with ProcessBuilder and create a List<Process>
    2) Wrap each Process into a ShellScriptProcess and acquire a List<ShellScriptProcess>

    class ShellScriptProcess implements Runneable() {
    
      private Process process;
      public ShellScriptProcess(Process process) {
         this.process=process;
      }
    
      boolean synchronized finished = false;
      public void run() {
        process.waitFor(); //this will wait until the process terminates
        finished = true;
      }
      public boolean isFinished(){
        return finished;
     }
    }
    

    3) wait for processes to finish

    while(!allFinished) {
        for (ShellScriptProcess sp : shellScriptProcesses) {
          allFinished = true;
          if (sp.isFinished()) {
              // hurray, a process has finished, inform the UI
              // you want to do something smarter here though, 
              //like removing the finished processes from the list
          }
          else {
              allFinished = false;
          }
       }
    }
    

    This is only a very rough solution, just to demonstrate the idea of how this could be acomplished. And I didn’t test the code, it might contain of syntax errors 🙂 Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing front-end code for a web application, and ran into an odd piece
I am developing an asp.net 3.5 web application which is running perfectly on my
Im Developing a web application which is very critical. So authentication has to be
I am developing a web application which follows the principle of responsivness. Every information
I am developing a web application which reads data from excel file (xlsx). I
I am developing a web application which contains a user login. In the web
I am developing a web application which will be added as a custom page
I'm developing a web application which is required to call a custom registered protocol
I am developing a web application with which user can view files in the
I'm currently involved with developing a C# CMS-like web application which will be used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.