Method call order

Hello everyone I am writing a java class with a main method and I am calling a method from matlab which takes a long time and the program runs another method which takes less time before the matlab method. I want to run a method from matlab to execute first, then I want another method to execute, so you can help me.

thanks

+1


a source to share


3 answers


Sounds like you need threads. You can find the Sun concurrency tutorial .

Basically, you can do something like this:



public static void main(String[] args) {
    Runnable r = new Runnable() {
        public void run() {
            doMethod();
            doOtherMethod();
        }
    }
    new Thread(r).start();
    doAnotherMethod();

      

See also the Javadocs for Thread

and Runnable

.

+2


a source


Have a look at the java.util.concurrent package. It has functions for performing tasks in parallel and coordinating tasks.



0


a source


I think you want to use Matlab's Thread join () method to wait for the thread to end before moving on to another method.

I'm not sure if this means what you mean by "method from Matlab to execute first, then I want another method to execute".

I just do not know. The question is interesting, but why did you not provide the code that you use to call the matlab method, as you say: "I am calling the method from Matlab". Perhaps if you showed how?

0


a source







All Articles