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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:45:40+00:00 2026-05-26T03:45:40+00:00

In my program, I connect to an interpreter process for another language. I need

  • 0

In my program, I connect to an interpreter process for another language. I need the program sometimes to ask the interpreter several things and use it’s response.

The process is stored in a IProcess variable and the communication is done via the IStreamsProxy of the process. to recieve the response, I added an IStreamListener to the IStreamsProxy.

However, when I write to the IStreamsProxy (with the write() method), I need the code to wait for the response, e.g. the streamAppend-method of the listener to be called.

I tried to use the wait() and notify() method, but I don’t know on what objects I should call them.

The query class which makes the communication calls a method like this:

/**
 * Sends a command to the interpreter. Makes the current thread wait for an answer of the interpreter.
 * @throws IOException 
 */
private synchronized void send(String command) throws IOException{
    this.s48Proxy.write(command);
    try {
        System.out.println("waiting for reply");
        this.wait();
    } catch (InterruptedException e) {
        System.out.println("interruption exception: "+e.getMessage());
    }
}

and the listener:

private class Listener implements IStreamListener {

    private Query query;

    public Listener(Query query) {
        super();
        this.query = query;
    }

    @Override
    public void streamAppended(String arg0, IStreamMonitor arg1) {
        System.out.println("got interpreter answer");
        query.setCurrentOutput(arg0.substring(0, arg0.lastIndexOf("\n")).trim());
        query.notify();
    }
}

The streamAppend() method calls the notify()-method on the query class. However, this does not work. “Waiting for reply” is the last response I get.

How can I do this? Or are there any other methods I could use to achieve this automatically?

  • 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-26T03:45:40+00:00Added an answer on May 26, 2026 at 3:45 am

    You could use Object#wait & Object#notifiy.

    // @ IStreamsProxy
    synchronized( someMonitor ) {
      someMonitor.wait( /* time? */ );
    }
    
    // @ Listener
    synchronized( someMonitor ) {
      someMonitor.notify();
    }
    

    -> Javadoc Link

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

Sidebar

Related Questions

HyperTerminal is a program that you can use to connect to other computers, Telnet
I have a large Prolog program with lots of predicates. I need to connect
Can you use COM/OLE in a C# program to connect to a running instances
I'm running out of file descriptors when my program can't connect another host. The
I write a program with netbeans. I connect my program to mysql an use
I've been struggling to get a Java program to connect to MS SQL Server,
I'm trying to write a program that uses sockets to connect with other instances
I have written an ActionScript client program that tries to connect to a local
I am trying a program with Swing. I am using a socket to connect
I've got a PHP command line program running. And I want to connect to

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.