I suppose I may have been unsuccessful in my description, so I'll try to add some more detail. First I'll talk about what matlab is and my interface to it, talk about some details of my software, and then try to rephrase my question.
MATLAB AND THE INTERFACE TO IT
Matlab is commerical programming software usually used for matrix calculations.
I have a separate software, similar to
Flowmaster, which requires the capabilities of matlab for complex matrix calculations. I have developed a GUI using the
JGraph component to enter the data.
I can then launch my application from within Matlab, and from there, send data and commands back to Matlab to perform the analysis that is required. (It is not possible to make this link in any other way).
When I launch my application (from within the Matlab GUI), the first thing I need to do is create a new thread, so that the user can continue to interact separately with Matlab, while concurrently interacting with my software. If I do not create a new thread, the user was be unable to interact with Matlab until my application is closed. Basically, my application is encapsulated within a separate thread from the thread running the Matlab GUI.
Now, eventually, the user may wish to exit my application (in the normal way from within the application), but not exit Matlab. However, if I call
the matlab will also shutdown because the JVM exits. So what I need is some way to the thread for my software, without exiting the JVM.
In essence, you are correct in seeing two separate programs, that are sharing one instance of the JVM.
MY APPLICATION
My application itself it designed similar to MS
Word (Single document interface). There can be several windows (frames), but there is only one instance of the application. These various frames are all linked together via a common "application" class, which is just a generic
, which handles creating windows, event redirection to the currently selected window, etc.
Thus, when I create my application from within matlab, I create an instance of this class which in addition to many other things common to all of the possible SDIs, creates an initial SDI.
MY QUESTION
I understand that when the run method exits, the thread is complete, but I am unsure when this occurs. It's not as if there is a clear end point as in a modal dialog.
So here's my question(s). When does my thread die, and how can I kill it from within itself?
I hope this clarifies my problem.