From: Walter Roberson on
Paul Carpenter wrote:

> I had considered using '&' in the system command, but then I do not
> believe that Matlab would wait for the status and result response,
> correct? I do want to wait for these...

In that case you will need to go non-portable, at least in theory. In the
systems other than Windows you can mex up some code that invokes the routine
via popen(); in Windows XP SP2 or later in _theory_ popen() should work but
that's an implication from other documentation and specific support for
popen() is not well documented.


> However, what I really want is
> for Matlab to respond to a button press while the current command is
> executing, which causes another system() command to run that sends a
> signal to the executing process, causing it to clean-up and exit
> gracefully. When I click on the "Stop" button while the first command
> is executing it seems like the GUI takes the press, but it appears that
> the processing of the callback happens after the first command is
> completed, thus defeating the purpose of my Stop button..... So what I'd
> really like to know is that Matlab GUI is multi-threaded and can thus
> handle processing more than one linux shell at a time.

No it is not.

> I hope this is
> not a limitation of Matlab because if it is, I cannot see it ever
> becoming a widely adopted platform for production quality user interfaces.

The documentation about interrupts makes it fairly clear that the most a
graphics callback can do if a routine is already running is to be queued until
that callback is finished or one of a series of requests is made by the
program (drawnow(), pause(), create a new figure, and a couple of others.)

Somewhere around a month-ish ago, someone explored and found that at least
with fairly new Matlab versions, timers are an exception to this and that
timers can interrupt between any two .m lines.

There is some amount of threading that can be done at the Java level, but
graphics in particular (and some other forms of computation) must go through
the single Java thread that is created for Matlab.

Beyond that, Matlab multi-threading without the distributed processing toolkit
is limited to use of multiple cores by some of the high performance numeric
routines.