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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:03:31+00:00 2026-06-05T14:03:31+00:00

I have developed an application which is intended to allow users to execute queries.Once

  • 0

I have developed an application which is intended to allow users to execute queries.Once the user enters the query and clicks on execute button the control is passed to RMI server which in turn starts the thread.

User should be able to execute other quesries one after the other and each query will b executed in different thread.

I am not able to stop the execution of the thread. I want to stop the execution while it is executing or on the button click event based on the thread id passed.
I am trying below code

public class AcQueryExecutor implements Runnable {  
    private volatile boolean paused = false;     
    private volatile boolean finished = false;  
    String request_id="",usrnamee="",pswd="",driver="",url="";   

    public AcQueryExecutor(String request_id,String usrnamee,String pswd,String driver,String url) {  
        this.request_id=request_id;   
        this.usrnamee=usrnamee;   
        this.pswd=pswd;   
        this.url=url;   
        this.driver=driver;   
    }   

    public void upload() throws InterruptedException {   
        //some code                
        stop();
        //some more code
    }   

    public void run() {   
        try {   
            while(!finished) {   
                upload();   
            }
        } catch (InterruptedException e) {   
            e.printStackTrace();   
        }   
    }   

    public void stop() {
        finished = true; 
    }
}  

RMI server class from where I start the thread

        public class ExecutorServer extends UnicastRemoteObject implements ExecutorInterface

        {
        public ExecutorServer()throws RemoteException
        {
        System.out.println("Server is in listening mode");
        }
        public void executeJob(String req_id,String usrname,String pwd,String driver,String url)throws RemoteException  
{
    try{
    System.out.println("Inside executeJob.wew..");
    AcQueryExecutor a=new AcQueryExecutor(req_id,usrname,pwd,driver,url);
    Thread t1 = new Thread(a);
    t1.start();
    }
    catch(Exception e)
    {
        System.out.println("Exception " + e);
    }

}           
        public void killJob(String req_id)throws RemoteException{
            logger.debug("Kill task");  
            AcQueryExecutor a=new AcQueryExecutor(req_id,"","","","");
    a.stop();
                    }


        public static void main(String arg[])
        {
        try{
            LocateRegistry.createRegistry(2007);
        ExecutorServer p=new ExecutorServer();
        Naming.rebind("//localhost:2007/exec1",p);
        System.out.println ("Server is connected and ready for operation.");
        }catch(Exception e)
        {
        System.out.println("Exception occurred : "+e.getMessage());
        e.printStackTrace();
        }
        }
               }

RMI client

 ExecutorInterface p=(ExecutorInterface)Naming.lookup("//localhost:2007/exec1");
            System.out.println("Inside client.."+ p.toString());
                   p.executeJob(id, usrname, pswd);
                 p.killJob(id);
            }

Till my knowlegde p.killJob() will wont be invoked untill executeJob() is finished.
I want to stop the execution while it is running

  • 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-05T14:03:33+00:00Added an answer on June 5, 2026 at 2:03 pm

    The problem appears to be that you are allocating a fresh instance of the Runnable AcQueryExecutor for each thread. This means each is seeing its own finished flag. Setting one in killJob will not lead to any other thread exiting because no other thread shares this flag.

    You’ll need to share Runnables or else make the finish field static. The latter will cause all threads to exit whenever any instance’s stop is called, so may not be what you want.

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

Sidebar

Related Questions

I have developed a application in which user select the particular folder and it
I have developed a application in which user select the particular folder and it
Hai I have developed a standalone application in which when an user logs in,
We have developed a web application which consumes a web service. The user will
Have developed an MVC3 application which monitors when users access static content on the
I have developed an android application in which some OK button (soft key) is
I have developed one application in which i have to detect whether user has
I have developed an application which allows the user to switch between themes. I'm
I have developed one application in which i need to register a user in
I have developed a java application which run's perfectly in local server. But When

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.