Java Builder - Multithreading issues
Afficher commentaires plus anciens
Hello!
I built and compiled my first serious Matlab program to Java class using the Java Builder. I wrote Java driver, which converts the necessary data types from Java to Matlab.
But now I have a problem - I try to use the same class in two parallel threads in my Java application and keep getting exceptions. When I run only one thread it works fine. What can be the problem? Please help me...
Update:
My intention is to use a Random Forest Ensemble, trained previously in Matlab, in a Java application. My Matlab function, which I compiled, using deploytool is:
function [Probability]=PredictingTest (Predictor)
load (['D:/Test/Tree.mat'], 'Tree')
[~, prob]=predict(Tree , Predictor);
Probability=prob(:,1);
end
Where:
Predictor input is an integer between -10 to 10. Probability output is a double between 0 to 1. Tree is a .mat file with a CompactTreeBagger object stored in it. Next I deploy the jar files to my Eclipse project, and try to run this Java code:
/* Necessary package imports */
import com.mathworks.toolbox.javabuilder.*;
import PredictTest.*;
public class predict_test {
static MWNumericArray rhs = null; /* Stores input value */
static PredictTest prediction;
static Object[] result = null; /* Stores the result */
public static void main(String[] args) {
try {
prediction = new PredictTest();
rhs=new MWNumericArray(5,MWClassID.DOUBLE);
result=prediction.PredictingTest(1, rhs);
}
catch (MWException e) {
e.printStackTrace();
}}}
Segmentation violation detected at Fri Jul 08 12:02:26 2011:
Configuration:
MATLAB Version: 7.11.0.584 (R2010b)
Processor ID: x86 Family 6 Model 14 Stepping 5, GenuineIntel
Virtual Machine: Java 1.6.0_22-b04 with Sun Microsystems Inc. Java HotSpot™ Client VM mixed mode
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!