我有2个单独的pthread和一个静态struct数组.其中一个pthread写入解码对象,包括字节,大小,宽度和高度.另一个pthread实际上正在读取堆栈并进行一些图像处理并将结果发布到java函数中.
这是问题,在pthread1上我将jbytearray转换为unsigned char*,并存储到静态数组上的位置0.
但是当pthread2将其转换回jbytearray时会发生一些事情并且我总是会发出致命的信号.
这是我的cpp类的顶部
struct DecodeObject {
unsigned char* data;
int data_size;
int width;
int height;
int orientation;
};
static int decodeLimit = 200 ;
static DecodeObject decodeList[200] ;
static int decodeSize = -1 ;
Run Code Online (Sandbox Code Playgroud)
这是我的pthread1的一部分
//Values
jbyteArray imageData = (jbyteArray) env->CallObjectMethod(decodeObject,getData);
jint width = (jint) env->CallIntMethod(decodeObject,getWidth);
jint height = (jint) env->CallIntMethod(decodeObject,getHeight);
jint orientation = (jint) env->CallIntMethod(decodeObject,getOrientation);
if(decodeSize<decodeLimit-1){
DecodeObject object;
object.data_size = env->GetArrayLength (imageData);
object.data = as_unsigned_char_array(env,imageData);
object.width = width;
object.height = height;
object.orientation = orientation;
decodeSize++;
decodeList[decodeSize] = …Run Code Online (Sandbox Code Playgroud)