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 5975765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:07:57+00:00 2026-05-22T21:07:57+00:00

Is it possible to use threads in bash scripts. I have a driver class

  • 0

Is it possible to use threads in bash scripts. I have a driver class in java that i’m trying to run multiple instances of at the same time. The only way i know to do this is make threads in bash, but i’m not sure if thats even possible. Any help would be 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-22T21:07:58+00:00Added an answer on May 22, 2026 at 9:07 pm

    Bash doesn’t support threading per se, but you could launch multiple java processes in the background, like:

    java myprog &
    java myprog &
    java myprog &
    

    Anything more than that you might look into Python or Ruby, which have thread management utilities, you could wait for each one to finish and collect output/exit status, etc.

    Edit: Borrowing the suggestion from @CédricJulien to use wait, here’s a more thorough example. Given this MyProg.java program:

    public class MyProg {
        public static void main(String[] args) {
            System.exit(Integer.parseInt(args[0]));
        }
    }
    

    you could write the following bash-threads.sh script to launch multiple instances of it in parallel:

    #!/bin/bash
    set -o errexit
    
    java MyProg 1 &
    pid1=$!
    java MyProg 0 &
    pid2=$!
    java MyProg 2 &
    pid3=$!
    
    wait $pid1 && echo "pid1 exited normally" || echo "pid1 exited abnormally with status $?"
    wait $pid2 && echo "pid2 exited normally" || echo "pid2 exited abnormally with status $?"
    wait $pid3 && echo "pid3 exited normally" || echo "pid3 exited abnormally with status $?"
    

    Its output is:

    pid1 exited abnormally with status 1
    pid2 exited normally
    pid3 exited abnormally with status 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few bash scripts I run, but they can take several hours
Is it possible/recommended to use background worker threads with the web browser control? I
I have recently started looking into Google Charts API for possible use within the
I want to use threads in ASP.NET web application. Is it possible to use
It is theoretically possible to use a boost library (e.g. boost threads) inside a
Possible Duplicate: Making a log4j console appender use different colors for different threads I
When I use putStrLn txt from several threads in Haskell, it's possible to get
I have a program that spawns 3 worker threads that do some number crunching,
Let me first say that I have quite a lot of Java experience, but
Here some C++ code that is accessed from multiple threads in parallel. It has

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.