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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:48:08+00:00 2026-06-11T02:48:08+00:00

I have two linux machines. On one machine I’m using a thread which starts

  • 0

I have two linux machines. On one machine I’m using a thread which starts up an executable and another internal thread reads the data from the executable and populates the database with the values from the executable, I’m using myBatis to persist the data. Later it continuously checks if the process and the internal thread is up and running. On the other machine I have the database connected remotely which is continuously deployed every night, due to this the database is being dropped and recreated. So as the database table is not available during this build an exception:

org.apache.ibatis.exceptions.PersistenceException 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Table 'updates_table' doesn't exist

is thrown. Then the thread which is continuously checking for the process and internal thread is killed and it stops checking.

Can anyone help me how to handle the thread from not being killed and once the db is available and running it should try to repopulate the table. when the db is not available it should always keep trying until the db is available.

Thank you.

  • 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-11T02:48:10+00:00Added an answer on June 11, 2026 at 2:48 am

    Consider switching to a system where you submit jobs to an Executor from the thread pulling stuff off of the process:

    public class MyThread extends Thread {
        private final InputStream processStream;
        private final Executor executor = Executors.newSingleThreadExecutor();
    
        public MyThread(InputStream processStream) {
            this.processStream = processStream;
        }
    
        @Override
        public void run() {
            while ([processStream has stuff]) {
                final Object obj = // Get your object from the stream
                executor.execute(new Runnable() {
                    @Override
                    public void run() {
                        // Do database stuff with obj
                    }
                });
            }
        }
    
        private static Object getSomethingFromStream(InputStream stream) {
            // return something off the stream
        }
    }
    

    If an exception is thrown by your Runnable, it will be logged, but it won’t be stopped, and it will just continue to the next job in the queue. Also note that this is using a single-threaded executor, so everything submitted will be executed one at a time, and in the order they’re submitted. If you want concurrent execution, use Executors.newFixedThreadPool(int) or Executors.newCachedThreadPool(). Note that this answers how to keep your thread alive. If you want to resubmit a runnable for re-execution if the job fails, change its run method to:

    @Override
    public void run() {
        try {
            // Do database stuff with obj
        } catch (PeristenceException ex) {
            // Try again
            executor.execute(this);
        }
    }
    

    You can add logic to this to tailor when it will try again on an exception.

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

Sidebar

Related Questions

We have two machines which need to communicate: a Linux based gateway, and a
I have two ubuntu linux boxes: I'm in bash on one machine running some
I have a two server machines on which I have installed Linux servers.I want
I have two legacy machines connected to a Linux box with USB using the
I have two Linux Machine,1st is machine X ,other is machine Y i want
I have two linux boxes. Both Fedora 11 x64. On one, I downloaded the
I have two classes (MVC view model) which inherits from one abstract base class.
I have two Linux (CentOS 6.0) machines over here and I need to add
I am new to C programming. I have two Linux machine. I want to
see basically i have one multi-thread application in which i want to see the

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.