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

  • SEARCH
  • Home
  • 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 943505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:26:53+00:00 2026-05-15T22:26:53+00:00

Im trying to implement a scenario using threads to execute concurrent commands on a

  • 0

Im trying to implement a scenario using threads to execute concurrent commands on a server. The commands just send requests to a service running on the server and in return get the required output.

The commands are generated based on reading a file, whose path the user gives as input to the application.
Based every line that is in the aforementioned file, a command is generated and run on the server.
Im running these commands by invoking an instance of the bash process on the linux box.
A brief pseudo implementation of the above is as follows.

Class A {
public static void main(blah blah)
//take all user inputs, one of which is the location of the file that is to be read.
try {
            Runnable runnable =new bckwork(//pass the inputs taken from the user//);
            thread = new Thread(runnable);
            thread.start();
        }
        catch (Exception e) {
           e.printStackTrace();
        }
}

and the class that does the actual work —

public class bckwork implements Runnable {

bckwork(//takes in all input that the other class passes on) {
        //assigns to local variables
    }
public void run() {
        // TODO Auto-generated method stub
    try{
        Process proc = null;
        proc = Runtime.getRuntime().exec("/bin/bash", null, dir);
         if (proc != null) {
          String cmd="";
          BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));

          PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())), true);

           BufferedReader br = new BufferedReader(blah blah blah);//reads every line in the file that was passed onto this class.
              String strLine;
          while ((strLine = br.readLine()) != null)   {
                 cmd=blah+blah+blah//the command is generated,whatever is read off the file is a part of the command.
                 out.println(cmd);
             String line;
              while ((line = in.readLine()).length()>1) {
                    line = in.readLine();
                    System.out.println(line);
                    proc.waitFor();
                    in.close();
                    out.close();
                    proc.destroy();
                      }
        }
}
}catch(Exception e){}
}
}

The problem with the above pieces of code is that they run only for the first line in the file that is being read and then the executions goes into some kind of deadlock. Im guessing that the next line from the file is never being read.My intention was to kick of a thread for every line that was being read or essentially every command that was being constructed.

Any pointers on how this bug can be corrected would be greatly appreciated.

  • 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-05-15T22:26:54+00:00Added an answer on May 15, 2026 at 10:26 pm

    In

    while ((line = in.readLine()).length()>1) 
    

    in.readLine waits for enter and freezes the entire application.

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

Sidebar

Ask A Question

Stats

  • Questions 517k
  • Answers 517k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer OK, I have solved the problem. Essentially, it is a… May 16, 2026 at 7:51 pm
  • Editorial Team
    Editorial Team added an answer That's what GL_REPLACE does, the final fragment color is the… May 16, 2026 at 7:51 pm
  • Editorial Team
    Editorial Team added an answer This is really strange and seems to be a bug.… May 16, 2026 at 7:51 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to implement this scenario using Unity and i can't figure out how
we are trying to implement an application using the Service Layer Pattern cause our
I'm trying to implement a Cometd/Bayeux server on Android using iJetty. The Jetty implementation
I am trying to implement a scenario using JSF. I have a commandExButton and
I got a little problem here guys. I'm trying to implement the following scenario:
I am trying to understand how the following scenario could be implemented using reactive
Im trying to implement fade in effect to my mp3 player. I´m using FloatControl
I'm trying to implement a pattern I read from Don Syme's blog ( https://blogs.msdn.microsoft.com/dsyme/2010/01/09/async-and-parallel-design-patterns-in-f-parallelizing-cpu-and-io-computations/
I have been trying to solve this Concurrent Programming exam exercise (in C#): Knowing
I'm trying to model a asynchronous job processing framework using MailboxProcessor. My requirements are

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.