Using coreFoundation in multiple threads

28 views
Skip to first unread message

Сергей Матвеев

unread,
Oct 11, 2017, 11:08:18 AM10/11/17
to crystax-ndk
While trying to port NSDictionary to Android I stopped on following problem:

I have multiple threads in my java app, first thread calls native function which construct  singleton object:

[[DocumentManager instance] setPath:path]; // initialize static variable with DocumentManager

Second thread calls native function which do folowing:

[[DocumentManager instance] loadDoc:key]; //  I have  SIGSERV when loadDoc called on static variable behind the singleton


Everything works fine If I call this 2 native methods on the same java thread, but when I try to access to objc object from diffrent java threads I have SIGSERV.

Also I try to return DocumentManager pointer from first method to java and then call second native method with this pointer like this:

DocumentManager* dm = (DocumentManager*)pointerFromJava;
[dm loadDoc:key]; // SIGSERV

Also I try to store pointer in global static variable in JNI.

I use noarc build and 10.3.1 version, so the question is how to use created object across jni calls and multiple threads (in single thread all works fine)?







Reply all
Reply to author
Forward
0 new messages