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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:05:18+00:00 2026-05-26T01:05:18+00:00

My program involves a number of JAVA threads calling a KornShell (ksh) script file

  • 0

My program involves a number of JAVA threads calling a KornShell (ksh) script file with different parameters. This script file in turn calls some SQL commands
which return some status. I store this status in a variable as a part of the script and check the value returned from SQL and take appropriate actions.
The problem is that all scripts are being executed in the same session and thereby the variable name gets shared across all threads. Since these threads are working asynchronously, I want this link to be broken. The easiest solution that I could come up with was to have a different variable for each thread (use some input parameter to the script as an identifier) but this would mean that the name of that variable needs to be dynamic. That is, I should be able to use the value of a variable in the name of another variable.
Is this even possible? If it is then how do I do it ?

Java Thread – | Same session |
| |
Java Thread – – | Same Script |
| |
Java Thread – – – | Same var name |
| |
Java Thread – – | (This same var |
| name can cause |
Java Thread – | Inconsistencies)|

If not, then can anyone suggest an alternative approach? An important aspect of this is the far that the JAVA part is a server program and will be running for extended durations so I will need to ‘unset’ these variables manually. (Something I can’t do if i am using an array to store all of these)

  • 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-26T01:05:19+00:00Added an answer on May 26, 2026 at 1:05 am

    … I store this status in a variable as a part of the (ksh) script and check the value returned from SQL and take appropriate actions. The problem is that all scripts are being executed in the same session and thereby the variable name gets shared across all threads.

    So to summarize:

    • each thread uses System.exec(...) or equivalent to run a ksh script

    • the ksh script uses a variable to store the status from running an SQL query.

    In this scenario, the ksh variable will NOT be shared between the different instances of the running script. Each ksh instance has its own variable set.

    There must be another explanation for what is going on here.


    You say that if [ $var_$val -eq 0 ]; then ... gives the wrong answer. I’m not surprised. $var_$val cannot possibly expand to a number, so the test to see if it is zero will always fail.

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

Sidebar

Related Questions

I am working on implementing a simulated annealing program and part of this involves
Almost any mature program that involves text implements double click to select the word
I'm writing a program that involves playing back sine waves and combinations of sine
I have a speed critical multithreaded program which involves data in a tree structure.
I am working on a c++ win32 program that involves a keyboard hook. The
I'm working on a program for class that involves solving the Chinese Postman problem
JAVA- Hi, I am writing a minesweeper program (first biggie) and am really stuck.
I'm building some application, the involves training programs. my issue is like this, A
I'm writing a script that logs errors from another program and restarts the program
I'm writing a program that involves a ton of images, over 100 per screen

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.