【发布时间】:2015-05-02 12:50:39
【问题描述】:
我写了下面的代码,我的问题是,我想将数据从 FICSR 类传递到主类。我试图在 FICSR 类的构造函数中声明“在 calcFICS() 方法中提到的 ArrayList”,但之后我发现我无法在里面使用它们 calcFICS() 方法,为什么?以及如何解决。
主类:
public static void main(String[] args) {
MatFactory matFactory = new MatFactory();
FilePathUtils.addInputPath(path_Obj);
Mat bgrMat = matFactory.newMat(FilePathUtils.getInputFileFullPathList().get(0));
if (bgrMat != null) {
if (!bgrMat.empty()) {
fiCSR = new FICSR(bgrMat, SysConsts.MIN_CS_RADIUS);
} else {
Log.E(TAG, "MainClass", "bgrMat is empty");
}
} else {
Log.E(TAG, "MainClass", "bgrMat is null");
}
FISR 类:
public FICSR(Mat bgrMat, int csRadius) {
// TODO Auto-generated constructor stub
this.bgrMat = bgrMat;
this.csRadius = csRadius;
this.fiCS_R3 = new Thread(new FICS(this.bgrMat, this.csRadius), "FICS_R" + this.csRadius);
fiCS_R3.start();
}
private class FICS implements Runnable {
private Mat bgrMat;
private int csRadius;
public FICS(Mat bgrMat, int csRadius) {
// TODO Auto-generated constructor stub
this.bgrMat = bgrMat;
this.csRadius = csRadius;
}
public void run() {
// TODO Auto-generated method stub
calcFICS(this.bgrMat, this.csRadius);
}
public static void calcFICS(Mat bgrMat, int csRadius) {
// TODO Auto-generated method stub
ArrayList<Mat> onOffCSActRegMatsList = null;
ArrayList<Mat> offOnCSActRegMatsList = null;
ArrayList<Mat> onOffCSFullMatsList = null;
ArrayList<Mat> offOnCSFullMatsList = null;
onOffCSActRegMatsList = new ArrayList<Mat>();
offOnCSActRegMatsList = new ArrayList<Mat>();
onOffCSFullMatsList = new ArrayList<Mat>();
offOnCSFullMatsList = new ArrayList<Mat>();
//here I want to add values to the ArrayLists defined above and return them to the main class. how can I do that?
... ... ...
【问题讨论】:
-
这两个类在同一个包中吗?
-
@AADTechnical 是的...如果它们在同一个 cpackage 中,会有所帮助吗??
标签: java multithreading arraylist