title: Error when calling compiled m-file(.jar) in a multi threaded Java app
body: <p>I have a simple m-file</p>
  
  <pre><code>function [fRate,Height,Width] = media(filename)  
  obj = mmreader(filename);  
  fRate = obj.FrameRate;  
  Width = obj.Width;  
  Height = obj.Height;  
  end
  </code></pre>
  
  <p>Which I have successfully compiled using MATLAB Builder JA into a .jar file.</p>
  
  <p>I have tested the .jar file in a single threaded application and it work with no problem.</p>
  
  <p>The error came when I use it in a multi threaded GUI application. I run the .jar as a thread in one of the class I created and the following error occur.</p>
  
  <blockquote>
    <p>An unexpected error has been detected
    by Java Runtime Environment:  </p>
    
    <p>EXCEPTION_ACCESS_VIOLATION
    (0xc0000005) at pc=0x6d9c08b0,
    pid=5920, tid=4788</p>
    
    <p>Java VM: Java HotSpot(TM) Client VM
    (10.0-b19 mixed mode windows-x86)
    Problematic frame: </p>
    
    <p>C  [jvm.dll+0x1108b0]</p>
  </blockquote>
  
  <p>After debugging, I found that the error occur when my thread is calling<br>
  <code>media = new Media();</code>  (I name my .jar as Media.jar)</p>
  
  <p>This is my Java code:<br>
  <code>
  // mediaProperty.java</p>
  
  <p>public class mediaProperty implements Runnable {</p>
  
  <pre><code>public void mediaProperty() {
  
      Matlab_options matlab = new Matlab_options();
      Object[] mediaProp = null;
      java.util.List lstMedia = new ArrayList();
      Media media = null;
  
      try {
  
          media = new Media();
          ...
  
          mediaProp = media.media(3, lstMedia);
  
          ...
      } catch (Exception p) {
          System.out.println("Exception: " + p.toString());
      } finally {
          MWArray.disposeArray(mediaProp);
          if (media != null) {
              media.dispose();
          }
      }
  }
  
  public void run() {
      mediaProperty();
  }
  </code></pre>
  
  <p>}<br>
  </code> </p>
  
  <p><code>  // GUI.java</p>
  
  <p>private Thread mediap;</p>
  
  <p>if (mediap == null) {<br>
  mediap = new Thread(new mediaProperty());<br>
  mediap.start();<br>
  }
  </code></p>
  
  <p>What is wrong? Is it my code? </p>